[Rcpp-devel] Designing Rcpp modules - allow access to fields or to field accessor methods?

2010-11-18 Thread Douglas Bates
My C++ coding style (such as it is) has been influenced by reading Frank Bokken's "C++ Annotations". I keep most data members of classes private or protected and usually with names like d_x, d_y, d_weights, etc. then provide accessor functions named x, y, weights, etc. Generally the accessors retu

Re: [Rcpp-devel] Designing Rcpp modules - allow access to fields or to field accessor methods?

2010-11-18 Thread Douglas Bates
Thanks again Romain. Now that you mention it I remember. On Thu, Nov 18, 2010 at 3:41 PM, Romain Francois wrote: > Le 18/11/10 22:31, Douglas Bates a écrit : >> >> My C++ coding style (such as it is) has been influenced by reading >> Frank Bokken's "C++ Annotati

[Rcpp-devel] Modules and default constructors

2010-11-19 Thread Douglas Bates
I believe it is now recommended that a class to be exposed in a module should expose a default constructor (i.e. a constructor called with no arguments). Is such a constructor actually called or is it just there to establish the necessary linkage? In a class where it would not make sense to const

Re: [Rcpp-devel] Convention on where to put RCPP_MODULE declarations?

2010-11-19 Thread Douglas Bates
Thanks to you and to Andrew for the responses. I will put the module declaration in a separate .cpp file. On Tue, Nov 16, 2010 at 2:50 AM, Romain Francois wrote: > Le 16/11/10 03:50, Douglas Bates a écrit : >> >> Is there any guidance on where to put RCPP_MODULE declaration

Re: [Rcpp-devel] Question concerning use of Raster in C vi Rcpp plugin and inline

2010-11-20 Thread Douglas Bates
On Tue, Nov 16, 2010 at 4:31 AM, Rainer M Krug wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > Hi > > I am new to C, and my question might be basic, but I am struggling with it: > > I have about 10 lines of code in a simulation, which take up about 50% > of the whole simulation, As th

Re: [Rcpp-devel] potential new way to expose constructors

2010-11-21 Thread Douglas Bates
That's fine with me. Sorry for the slow response. I'm down with a cold or the flu today. On Sun, Nov 21, 2010 at 1:52 PM, Romain Francois wrote: > Le 21/11/10 20:42, Andrew Redd a écrit : >> >> The init_2 is unnatural.  I would prefer the new syntax.  As I have to >> code that is relying in the

[Rcpp-devel] Preferred way to create an instance of a C++ class exported in a module?

2010-11-30 Thread Douglas Bates
I have seen a couple of ways of creating an instance of a C++ class exported in a module mod <- Module("myMod", "myPackage") cls <- mod$myClass inst <- cls$new(constructorArgs) and inst <- new(mod$myClass, constructorArgs) Is one of these the preferred way? _

Re: [Rcpp-devel] Preferred way to create an instance of a C++ class exported in a module?

2010-11-30 Thread Douglas Bates
set_data_path 6: module$set_data_path 7: fun(...) 8: doTryCatch(return(expr), name, parentenv, handler) ... > > Romain > > > > Le 30 nov. 2010 à 05:21 PM, Douglas Bates a écrit : > >> I have seen a couple of ways of creating an instance of a C++ class >> expo

Re: [Rcpp-devel] [Rd] GPL and R Community Policies (Rcpp)

2010-12-01 Thread Douglas Bates
Against my better judgement I will try to correct a misconception. I fear that my message will only fan the flames but I also think that if we are to be subjected to long, drawn out, personal attacks on this subject then the readers of this list are entitled to facts instead of speculation. On W

[Rcpp-devel] idiom for creating an informative message for an exception

2010-12-02 Thread Douglas Bates
In the lme4a package I mixed calls to Rf_error and throwing C++ exceptions. This is causing problems and I plan to replace the calls to Rf_error by exceptions so that there is a consistent approach. Many of the calls to Rf_error take advantage of the fact the Rf_error implicitly calls sprintf to

[Rcpp-devel] idiom for determining the (S3) class of an R object?

2010-12-02 Thread Douglas Bates
I currently use constructions like if (as(lst.attr("class")) != "family") throw std::runtime_error("glmFamily requires a list of (S3) class \"family\""); Is there a cleaner way that I haven't discovered yet. This method is error-prone because the S3 class of an object is a Ch

Re: [Rcpp-devel] Help with SubMatrix test case

2010-12-04 Thread Douglas Bates
On Fri, Dec 3, 2010 at 11:00 PM, Christian Gunning wrote: >> | The first three look correct to me: >> | i)   assign 3, 4, 5 >> | ii)  copy row 0 as 1 >> | iii) copy col 3 to 4 >> | >> | but I am also a little puzzled by the last submatrix. >> | >> | I'm sure Romain will weigh in in a few hours. >

Re: [Rcpp-devel] idiom for creating an informative message for an exception

2010-12-04 Thread Douglas Bates
Thanks very much, Romain. On Sat, Dec 4, 2010 at 8:13 AM, Romain Francois wrote: > Le 02/12/10 22:15, Douglas Bates a écrit : >> >> In the lme4a package I mixed calls to Rf_error and throwing C++ >> exceptions.  This is causing problems and I plan to replace the ca

[Rcpp-devel] Defining wrap methods for C++ classes that have data members of Rcpp types

2010-12-07 Thread Douglas Bates
I'm again trying to define instances of the wrap template for C++ classes that have data members defined in Rcpp.h A stand-alone example, which is rather lengthy, is enclosed. In this example I am unsuccessful in using the "intrusive" formulation described in the "Extending Rcpp" vignette. I wil

Re: [Rcpp-devel] Defining wrap methods for C++ classes that have data members of Rcpp types

2010-12-07 Thread Douglas Bates
On looking more closely I can't use cxxfunction with plugin="Rcpp" to test this because the plugin inserts #include before the user includes and some parts in the user includes need to be declared before Rcpp.h is included. I'll create a small package. On Tue, Dec 7, 2010

Re: [Rcpp-devel] Defining wrap methods for C++ classes that have data members of Rcpp types

2010-12-07 Thread Douglas Bates
nction( .., settings = settings ) > > I'm looking at the rest of the first email now. > > Romain > > Le 07/12/10 17:32, Douglas Bates a écrit : >> >> On looking more closely I can't use cxxfunction with plugin="Rcpp" to >> test this because the

Re: [Rcpp-devel] Interrupts in compiled code.

2010-12-08 Thread Douglas Bates
On Wed, Dec 8, 2010 at 3:02 PM, Dirk Eddelbuettel wrote: > > On 8 December 2010 at 13:41, Andrew Redd wrote: > | I have an MCMC chain that runs entirely in c++ with Rcpp.  It sometimes runs > | for a vary long time and I want to interrupt it.  Is there an efficient easy > | way to include catching

Re: [Rcpp-devel] idiom for creating an informative message for an exception

2010-12-10 Thread Douglas Bates
On Sat, Dec 4, 2010 at 8:13 AM, Romain Francois wrote: > Le 02/12/10 22:15, Douglas Bates a écrit : >> >> In the lme4a package I mixed calls to Rf_error and throwing C++ >> exceptions.  This is causing problems and I plan to replace the calls >> to Rf_error by ex

Re: [Rcpp-devel] Using namespaces to improve code readability

2010-12-17 Thread Douglas Bates
On Thu, Dec 16, 2010 at 5:18 PM, Savitsky, Terrance wrote: > I note that employing the namespace declaration -  using namespace arma; - > allows one to use the declaration of a new armadillo matrix under an > RcppArmadillo header with – mat X(Xr.begin() …. – instead of – arma::mat > X(Xr.begin() …

[Rcpp-devel] Documentation on Rcpp::XPtr class

2010-12-19 Thread Douglas Bates
I have been using external pointers through the Rcpp::Xptr class and have encountered memory problems that I think are related to the way I construct instances of this class. I have looked at Rcpp/inst/unitTests/runit.XPtr.R and at Rcpp/inst/include/XPtr.h (although I haven't read the latter caref

Re: [Rcpp-devel] Got error when trying to run example in Intro vignette

2010-12-21 Thread Douglas Bates
On Tue, Dec 21, 2010 at 11:21 AM, Gabor Grothendieck wrote: > I tried copying the example in the intro vignette >   http://dirk.eddelbuettel.com/code/rcpp/Rcpp-introduction.pdf > and get the following error. What's wrong? Hmm. The externally-callable function is being declared twice, perhaps due

Re: [Rcpp-devel] sugar performance

2010-12-22 Thread Douglas Bates
On Wed, Dec 22, 2010 at 5:33 AM, wrote: >  Hello, > > Following Gabor's thread yesterday, I looked into R source code and figure > that we don't need to test for NA when using numeric vector. See this: > > require(inline) > require(Rcpp) > > pl <- cxxfunction( , ' >    return List::create( >    

Re: [Rcpp-devel] Persistence of C++ changes in R.

2010-12-22 Thread Douglas Bates
On Wed, Dec 22, 2010 at 12:08 PM, Cedric Ginestet wrote: > Dear Rcpp Experts, > > I have encountered two issues when modifying an object within C++ function. > See the code below: > > ## > library(inline); library(Rcpp) > D <- matrix(rnorm(4),2,2) > src3 <-

Re: [Rcpp-devel] Persistence of C++ changes in R.

2010-12-23 Thread Douglas Bates
ricMatrix xD(clone(D)); >  xD(0,0) = 100.0; > return xD; > ' > passRef <- cxxfunction(signature(D="matrix"),body=src3,plugin="Rcpp") > passRef(D); D > ## > > > > On 22/12/10 18:32, Douglas Bates wro

Re: [Rcpp-devel] speed fix

2010-12-27 Thread Douglas Bates
On Mon, Dec 27, 2010 at 6:57 AM, Richard Chandler wrote: > Hi, > > I am trying to speed up a vectorized R function without much luck. Perhaps > it is not possible, but if it is could someone suggest how to improve the > C++/Rcpp code below? The speed is approximately equal on a 64-bit version of >

Re: [Rcpp-devel] speed fix

2010-12-27 Thread Douglas Bates
My apologies, I accidentally hit send on an incomplete message. On Mon, Dec 27, 2010 at 8:34 AM, Douglas Bates wrote: > On Mon, Dec 27, 2010 at 6:57 AM, Richard Chandler > wrote: >> Hi, >> >> I am trying to speed up a vectorized R function without much luck. Perhaps &g

Re: [Rcpp-devel] Summing over a numeric vector.

2011-01-03 Thread Douglas Bates
You forgot to initialize i in both loops. It should be for(int i = 0; i < Ne; i++) On Mon, Jan 3, 2011 at 9:50 AM, Cedric Ginestet wrote: > Dear Rcpp experts, > > I have the following bizarre problem. Although the second summing C++ > function seems easier than the former, it does not produce t

Re: [Rcpp-devel] Sugar seems slower than Rcpp.

2011-01-04 Thread Douglas Bates
On Tue, Jan 4, 2011 at 11:13 AM, Romain Francois wrote: > Le 04/01/11 17:42, Romain Francois a écrit : >> >> Le 04/01/11 16:35, Andrew Redd a écrit : >>> >>> Cedric, >>> This was addressed about 2 weeks ago on the list, please read the >>> archives. Basic point, Rcpp/sugar will not be faster than

Re: [Rcpp-devel] Sugar seems slower than Rcpp.

2011-01-04 Thread Douglas Bates
On Tue, Jan 4, 2011 at 12:04 PM, Douglas Bates wrote: > On Tue, Jan 4, 2011 at 11:13 AM, Romain Francois > wrote: >> Le 04/01/11 17:42, Romain Francois a écrit : >>> >>> Le 04/01/11 16:35, Andrew Redd a écrit : >>>> >>>> Cedric, >>>

Re: [Rcpp-devel] [Lme4-authors] got a minute to answer dumb questions about throw/catch in Rcpp?

2011-01-04 Thread Douglas Bates
rcpp-devel readers will be coming in to the middle of a conversation but it's all there if you want to catch up. On Tue, Jan 4, 2011 at 11:47 AM, Dirk Eddelbuettel wrote: > > Hi Ben, > > On 4 January 2011 at 12:24, Ben Bolker wrote: > | -BEGIN PGP SIGNED MESSAGE- > | Hash: SHA1 > | > |  

[Rcpp-devel] Loading a package using Rcpp Modules results in memory corruption

2011-01-05 Thread Douglas Bates
I don't know whether this is through error on my part or because of an "infelicity" in the Rcpp module code but the lme4a package, which now uses Rcpp modules extensively, ends up with some difficult-to-trace memory corruption issues. Yesterday i finally bit the bullet and ran a test with gctortur

Re: [Rcpp-devel] Loading a package using Rcpp Modules results in memory corruption

2011-01-05 Thread Douglas Bates
This time with the enclosure :-) On Wed, Jan 5, 2011 at 11:52 AM, Douglas Bates wrote: > I don't know whether this is through error on my part or because of an > "infelicity" in the Rcpp module code but the lme4a package, which now > uses Rcpp modules extensively, ends u

Re: [Rcpp-devel] Loading a package using Rcpp Modules results in memory corruption

2011-01-05 Thread Douglas Bates
from my point of view) that test didn't show any problems. I'm at a bit of a loss where to go on this. On Wed, Jan 5, 2011 at 11:55 AM, Douglas Bates wrote: > This time with the enclosure :-) > > On Wed, Jan 5, 2011 at 11:52 AM, Douglas Bates wrote: >> I don't know wh

Re: [Rcpp-devel] Loading a package using Rcpp Modules results in memory corruption

2011-01-05 Thread Douglas Bates
On Wed, Jan 5, 2011 at 2:15 PM, Douglas Bates wrote: > On looking more closely at the output, I thought that the problem may > arise in loading the Rcpp package because that is when the function > init_Rcpp_cache() is evaluated.  So I ran another test which was > simply > &

Re: [Rcpp-devel] Loading a package using Rcpp Modules results in memory corruption

2011-01-06 Thread Douglas Bates
On Wed, Jan 5, 2011 at 2:38 PM, Douglas Bates wrote: > On Wed, Jan 5, 2011 at 2:15 PM, Douglas Bates wrote: >> On looking more closely at the output, I thought that the problem may >> arise in loading the Rcpp package because that is when the function >> init_Rcpp_cache() is

Re: [Rcpp-devel] Loading a package using Rcpp Modules results in memory corruption

2011-01-06 Thread Douglas Bates
On Thu, Jan 6, 2011 at 9:54 AM, Douglas Bates wrote: > On Wed, Jan 5, 2011 at 2:38 PM, Douglas Bates wrote: >> On Wed, Jan 5, 2011 at 2:15 PM, Douglas Bates wrote: >>> On looking more closely at the output, I thought that the problem may >>> arise in loading the R

Re: [Rcpp-devel] FW: Installation issue for Rcpp_0.8.9 and Rcpp_0.9.0

2011-01-06 Thread Douglas Bates
On Thu, Jan 6, 2011 at 12:57 PM, Steve Moffitt wrote: > My mail server didn't like the attached installation script - I've resent it > with the script header removed. > > From: rcpp-devel-boun...@lists.r-forge.r-project.org > [rcpp-devel-boun...@lists.r-f

Re: [Rcpp-devel] Loading a package using Rcpp Modules results in memory corruption

2011-01-06 Thread Douglas Bates
In the continuing saga ... On Thu, Jan 6, 2011 at 12:57 PM, Douglas Bates wrote: > On Thu, Jan 6, 2011 at 9:54 AM, Douglas Bates wrote: >> On Wed, Jan 5, 2011 at 2:38 PM, Douglas Bates wrote: >>> On Wed, Jan 5, 2011 at 2:15 PM, Douglas Bates wrote: >>>> On look

Re: [Rcpp-devel] Loading a package using Rcpp Modules results in memory corruption

2011-01-06 Thread Douglas Bates
On Thu, Jan 6, 2011 at 2:19 PM, Douglas Bates wrote: > In the continuing saga ... > > On Thu, Jan 6, 2011 at 12:57 PM, Douglas Bates wrote: >> On Thu, Jan 6, 2011 at 9:54 AM, Douglas Bates wrote: >>> On Wed, Jan 5, 2011 at 2:38 PM, Douglas Bates wrote: >>>

Re: [Rcpp-devel] Loading a package using Rcpp Modules results in memory corruption

2011-01-06 Thread Douglas Bates
On Thu, Jan 6, 2011 at 2:37 PM, Douglas Bates wrote: > On Thu, Jan 6, 2011 at 2:19 PM, Douglas Bates wrote: >> In the continuing saga ... >> >> On Thu, Jan 6, 2011 at 12:57 PM, Douglas Bates wrote: >>> On Thu, Jan 6, 2011 at 9:54 AM, Douglas Bates wrote: >&

[Rcpp-devel] $ extraction from an Rcpp module causes error under gctorture

2011-01-06 Thread Douglas Bates
I finally managed to get an example from the Rcpp documentation to fail for me. Rcpp_module_class_error.R Description: Binary data Rcpp_module_class_error.Rout Description: Binary data ___ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org

Re: [Rcpp-devel] Loading a package using Rcpp Modules results in memory corruption

2011-01-07 Thread Douglas Bates
On Fri, Jan 7, 2011 at 5:34 AM, Romain Francois wrote: > Le 05/01/11 18:52, Douglas Bates a écrit : >> >> I don't know whether this is through error on my part or because of an >> "infelicity" in the Rcpp module code but the lme4a package, which now >> u

Re: [Rcpp-devel] Loading a package using Rcpp Modules results in memory corruption

2011-01-08 Thread Douglas Bates
e this today as I need a working version of lme4a by tomorrow. > On Fri, Jan 7, 2011 at 9:47 AM, Romain Francois > wrote: >> >> Hmm. I commited 2845 and 2846 today. >> >> Anyway, if you see it also with 0.9.0 this means more detective work. >> >> Le 07/01/11 15:

Re: [Rcpp-devel] Loading a package using Rcpp Modules results in memory corruption

2011-01-08 Thread Douglas Bates
On Sat, Jan 8, 2011 at 7:49 AM, Douglas Bates wrote: > On Sat, Jan 8, 2011 at 12:45 AM, Dominick Samperi wrote: >> I checked things under Linux and Windows (using GCC and VC++ DLL's) and the >> same problem occurs at the same place, which is a good sign when it comes

Re: [Rcpp-devel] Loading a package using Rcpp Modules results in memory corruption

2011-01-08 Thread Douglas Bates
On Sat, Jan 8, 2011 at 12:57 PM, Dominick Samperi wrote: > > > On Sat, Jan 8, 2011 at 9:48 AM, Douglas Bates wrote: >> >> On Sat, Jan 8, 2011 at 7:49 AM, Douglas Bates wrote: >> > On Sat, Jan 8, 2011 at 12:45 AM, Dominick Samperi >> > wrote: >>

Re: [Rcpp-devel] Loading a package using Rcpp Modules results in memory corruption

2011-01-09 Thread Douglas Bates
d appreciate your efforts in helping to debug this. I am trying a slightly different approach for the installation of the error indicator and codes from rcpp_tryCatch. > On Sat, Jan 8, 2011 at 2:06 PM, Douglas Bates wrote: >> >> On Sat, Jan 8, 2011 at 12:57 PM, Dominick Samperi &g

Re: [Rcpp-devel] Loading a package using Rcpp Modules results in memory corruption

2011-01-09 Thread Douglas Bates
On Sun, Jan 9, 2011 at 12:07 PM, Dirk Eddelbuettel wrote: > > On 9 January 2011 at 12:12, Dominick Samperi wrote: > | Actually, the problem seems to be pretty transparent, and the > | solution is the same (see below). This gets you through Evaluator, > | but you fail in SlotProxy in the call to "$

Re: [Rcpp-devel] Loading a package using Rcpp Modules results in memory corruption

2011-01-09 Thread Douglas Bates
On Sun, Jan 9, 2011 at 12:21 PM, Dominick Samperi wrote: > > > On Sun, Jan 9, 2011 at 1:07 PM, Dirk Eddelbuettel wrote: >> >> On 9 January 2011 at 12:12, Dominick Samperi wrote: >> | Actually, the problem seems to be pretty transparent, and the >> | solution is the same (see below). This gets you

Re: [Rcpp-devel] Loading a package using Rcpp Modules results in memory corruption

2011-01-11 Thread Douglas Bates
On Tue, Jan 11, 2011 at 12:27 PM, Dominick Samperi wrote: > > > On Tue, Jan 11, 2011 at 1:20 PM, Romain Francois > wrote: >> >> Le 11/01/11 19:12, Davor Cubranic a écrit : >>> >>> I think an important point from Doug has been lost in the subsequent >>> 20-odd messages of flamebombing: >>> > I

Re: [Rcpp-devel] Error running RInside examples

2011-01-14 Thread Douglas Bates
For the time being I would suggest using the released version of Rcpp instead of the latest package from R-forge. That is, install from a CRAN mirror site and not the R-forge site. There are some issues with the version currently in SVN. On Fri, Jan 14, 2011 at 10:45 AM, amao oluwole wrote: > H

Re: [Rcpp-devel] R.e. Debugging Rcpp packages with GDB

2011-01-19 Thread Douglas Bates
On Tue, Jan 18, 2011 at 6:19 PM, Dirk Eddelbuettel wrote: > > On 18 January 2011 at 15:52, Christian Gunning wrote: > | On Tue, Jan 18, 2011 at 2:46 PM, > | wrote: > | > > | > Can people share any tricks they use to debug Rcpp packages? For example, > can I "print" variables in a format that's a

Re: [Rcpp-devel] [Rd] Calling C++ from R

2011-01-21 Thread Douglas Bates
It is more effective to send such inquiries to the Rcpp-devel mailing list which I am cc'ing on this reply. On Thu, Jan 20, 2011 at 3:05 PM, mtck1982 wrote: > > Hi All, > > I am new to this area and use Rcpp to call C++ from R and try to build the > package under Windows 7. I use Rtools and R 2.1

Re: [Rcpp-devel] R.e. Debugging Rcpp packages with GDB

2011-01-25 Thread Douglas Bates
cs/gdb/Pretty-Printing.html.) Would people >> be interested in having Rcpp-specific pretty printers? >> >> That would be great. I have read about this feature ever since gcb 7.0 was >> announced but have never used. It probably would make a lot of sense here. >> >

[Rcpp-devel] Read-only property in Rcpp module, can it be a Vector& or must it be a Vector

2011-01-30 Thread Douglas Bates
As the Grateful Dead said, "What a long, strange trip it's been." I have spent over a month trying to debug some code in the lme4a package that uses Rcpp modules. Partly I was getting the wrong numerical answer, which was due to a dumb cut-and-paste error on my part - now fixed - but more importa

Re: [Rcpp-devel] Read-only property in Rcpp module, can it be a Vector& or must it be a Vector

2011-01-30 Thread Douglas Bates
On Sun, Jan 30, 2011 at 3:47 PM, Douglas Bates wrote: > As the Grateful Dead said, "What a long, strange trip it's been."  I > have spent over a month trying to debug some code in the lme4a package > that uses Rcpp modules.  Partly I was getting the wrong numerical >

[Rcpp-devel] Idiom for preserving an Rcpp object while passing back an external pointer?

2011-02-05 Thread Douglas Bates
As Dirk and Romain know I have been struggling to debug a memory protection problem that I encounter in code based on Rcpp Modules. As with all memory protection problems, it is very difficult to track down and I have kind-of run out of options right now. I plan, for the time being, to use code t

[Rcpp-devel] Installing RcppArmadillo under Ubuntu 10.10

2011-02-08 Thread Douglas Bates
I'm back to "it's not your night, kid". I seem to be unable to install the RcppArmadillo package under Ubuntu 10.10 with R-2.12.1 installed from the packages on CRAN. The compilation goes fine but the package can't be loaded because the symbol arma::arma_version::major is undefined. It should ha

Re: [Rcpp-devel] Installing RcppArmadillo under Ubuntu 10.10

2011-02-08 Thread Douglas Bates
On Tue, Feb 8, 2011 at 1:55 PM, Dirk Eddelbuettel wrote: > On 8 February 2011 at 13:42, Douglas Bates wrote: > | I'm back to "it's not your night, kid".  I seem to be unable to > | install the RcppArmadillo package under Ubuntu 10.10 with R-2.12.1 > | installed

Re: [Rcpp-devel] Installing RcppArmadillo under Ubuntu 10.10

2011-02-08 Thread Douglas Bates
On Tue, Feb 8, 2011 at 2:54 PM, Dirk Eddelbuettel wrote: > > On 8 February 2011 at 14:39, Douglas Bates wrote: > | On Tue, Feb 8, 2011 at 1:55 PM, Dirk Eddelbuettel wrote: > | > | > On 8 February 2011 at 13:42, Douglas Bates wrote: > | > | I'm back to "it

Re: [Rcpp-devel] Installing RcppArmadillo under Ubuntu 10.10

2011-02-09 Thread Douglas Bates
On Tue, Feb 8, 2011 at 3:49 PM, Douglas Bates wrote: > On Tue, Feb 8, 2011 at 2:54 PM, Dirk Eddelbuettel wrote: >> >> On 8 February 2011 at 14:39, Douglas Bates wrote: >> | On Tue, Feb 8, 2011 at 1:55 PM, Dirk Eddelbuettel wrote: >> | >> | > On 8 Februar

Re: [Rcpp-devel] [ANN] Rcpp 0.9.1

2011-02-14 Thread Douglas Bates
On Mon, Feb 14, 2011 at 12:45 PM, Dirk Eddelbuettel wrote: > > The new Rcpp 0.9.1 release is now on CRAN.  The NEWS entry is below; more > details are in the ChangeLog.  But in short, this is a mostly 'internal > fixes' release which addresses some issues in memory management which, while > not tr

Re: [Rcpp-devel] Building/linking trouble with cxxfunction()

2011-02-16 Thread Douglas Bates
On Wed, Feb 16, 2011 at 11:47 AM, wrote: > Hi, I'm having some trouble wrapping a relatively simple C function using > Rcpp and inline and friends.  This is my first time trying to use these > tools, so I'm sure I'm doing something wrong  my immediate problem is > that I can't seem to figure out

Re: [Rcpp-devel] Building/linking trouble with cxxfunction()

2011-02-16 Thread Douglas Bates
On Wed, Feb 16, 2011 at 2:03 PM, wrote: > On 2/16/11 12:18 PM, "Douglas Bates" wrote: >>The dgCMatrix object is of an S4 class.  It's best to use the S4 class >>from Rcpp so you can extract the slots as Rcpp::IntegerVector and >>Rcpp::NumericVector objects.

Re: [Rcpp-devel] Building/linking trouble with cxxfunction()

2011-02-19 Thread Douglas Bates
On Fri, Feb 18, 2011 at 4:50 PM, wrote: > On 2/16/11 3:55 PM, "Douglas Bates" wrote: >>I decided that it would be simple enough to write a small package to >>show exactly how you would pass a dgCMatrix to an Rcpp-based C++ >>function and create a smat object.

Re: [Rcpp-devel] [R] Help with integrating R and c/c++

2011-02-19 Thread Douglas Bates
On Sat, Feb 19, 2011 at 12:56 AM, Rohit Pandey wrote: > Hi Christopher/ Dirk, > Thank you very much for your replys. I think the idea of using inline as you > suggest is the best way to start off with using c++ with R. I went through > your examples and also plenty I found on the net. I have been

Re: [Rcpp-devel] Building/linking trouble with cxxfunction()

2011-02-22 Thread Douglas Bates
On Tue, Feb 22, 2011 at 10:53 AM, wrote: > > > On 2/19/11 9:20 AM, "Douglas Bates" wrote: > >>On Fri, Feb 18, 2011 at 4:50 PM,   wrote: >> >>> Hi Doug, did you ever get a test case working for this? >> >>I didn't try further.  I was

Re: [Rcpp-devel] Rcpp upgrading legacy code linking error

2011-03-09 Thread Douglas Bates
On Wed, Mar 9, 2011 at 9:14 AM, Dahir Alihassan wrote: > Hi, > > I am posting here upon Dirk's suggestion, as I understand this is well > attended to and I'd be grateful for any help. I am taking over a project > which involves upgrading to the latest version of Rcpp and thus I have to > upgrade a

Re: [Rcpp-devel] Rcpp compile question

2011-03-22 Thread Douglas Bates
On Tue, Mar 22, 2011 at 2:16 PM, Henry Bee wrote: > Hi Christian, > Thanks for the source file. Below are the full results as you requested. > It's giving the same error as before. Is 64-bit R supported? 64-bit R is supported. Has it already been established that you have the Rtools (compilers,

Re: [Rcpp-devel] error while calling function in loop

2011-03-28 Thread Douglas Bates
On Mon, Mar 28, 2011 at 1:31 PM, Sean Robert McGuffee wrote: > How hard is it to set up the list with a default reply to address of the > list? Making the change, not difficult. Convincing Dirk to make the change, very difficult. Google the phrase "Reply-to munging considered harmful". > > > O

Re: [Rcpp-devel] R.e. loadRcppModules

2011-04-12 Thread Douglas Bates
On Tue, Apr 12, 2011 at 1:11 AM, Romain Francois wrote: > Le 12/04/11 04:15, Christian Gunning a écrit : >> >> On Mon, Apr 11, 2011 at 3:00 AM, >>  wrote: >>> >>> >>> This will load the declared modules, and populate them into your >>> package's namespace. >>> >>> I will update the Rcpp-modules v

Re: [Rcpp-devel] Conflit with sys/vnode.h on Solaris (gcc 4.4.3)

2011-04-12 Thread Douglas Bates
On Tue, Apr 12, 2011 at 11:11 AM, Giuseppe Milicia wrote: > Dirk, > > I steer away from the Solaris compiler, too many headaches there... > > I'm currently using gcc 4.4.3 > > I tried rearranging the headers (in my code) but I got nowhere :( I suspect > this is the case because sys/vnode.h is use

Re: [Rcpp-devel] Cast for output of Rcpp Sugar runif()

2011-04-13 Thread Douglas Bates
On Wed, Apr 13, 2011 at 6:50 AM, Cedric Ginestet wrote: > Brilliant, Dirk. Thanks for that. > Next time, I'll read the Rcpp Sugar .pdf more carefully. > Cheers, Be aware that in both versions you will never return a vector containing b, which might be confusing. That is, the argument b should be

Re: [Rcpp-devel] Cast for output of Rcpp Sugar runif()

2011-04-13 Thread Douglas Bates
pe; > return rnorm(10, 0, 100); > > > Shall I use anything else? > Cheers, > > > On 13/04/11 13:59, Douglas Bates wrote: >> >> On Wed, Apr 13, 2011 at 6:50 AM, Cedric Ginestet >>  wrote: >>> >>> Brilliant, Dirk. Thanks for that. >&g

Re: [Rcpp-devel] R.e. loadRcppModules

2011-04-14 Thread Douglas Bates
On Thu, Apr 14, 2011 at 12:43 AM, Christian Gunning wrote: > On Tue, Apr 12, 2011 at 11:07 PM, Romain Francois > wrote: >>> >>> Just to clarify --  does your plan include storing user-modified >>> fields and properties in objects?  E.g. below, modtest with the msg >>> set? >> >> yes. Although the

Re: [Rcpp-devel] Boolean vector from R to C++

2011-04-14 Thread Douglas Bates
On Thu, Apr 14, 2011 at 10:00 AM, Cedric Ginestet wrote: > Hi all, > > I am trying to pass on a boolean vector from R to C++. I have naively tried > the following: > > > src <- ' >   using namespace Rcpp ; >   using namespace std ; >   int b = as(xb); > return wrap

Re: [Rcpp-devel] [R] Find number of elements less than some number: Elegant/fastsolution needed

2011-04-14 Thread Douglas Bates
My colleague Sunduz Keles once mentioned a similar problem to me. She had a large sample from a reference distribution and a test sample (both real-valued in her case) and she wanted, for each element of the test sample, the proportion of the reference sample that was less than the element. It's

Re: [Rcpp-devel] [R] Find number of elements less than some number: Elegant/fastsolution needed

2011-04-14 Thread Douglas Bates
mber that there is a findInterval function. > From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf > Of Douglas Bates [ba...@stat.wisc.edu] > Sent: Thursday, April 14, 2011 6:22 PM > To: William Dunlap > Cc: r-h...@r-project.org; Sunduz Keles; rcpp-devel; Kevin

Re: [Rcpp-devel] [R] Find number of elements less than some number: Elegant/fastsolution needed

2011-04-15 Thread Douglas Bates
On Thu, Apr 14, 2011 at 11:47 PM, Christian Gunning wrote: > On Thu, Apr 14, 2011 at 7:02 PM, > wrote: > >> I was able to write a very short C++ function using the Rcpp package >> that provided about a 1000-fold increase in speed relative to the best >> I could do in R.  I don't have the script o

Re: [Rcpp-devel] [R] Find number of elements less than some number: Elegant/fastsolution needed

2011-04-17 Thread Douglas Bates
ersus random access to the elements of y. On Fri, Apr 15, 2011 at 7:34 AM, Douglas Bates wrote: > On Thu, Apr 14, 2011 at 11:47 PM, Christian Gunning wrote: >> On Thu, Apr 14, 2011 at 7:02 PM, >> wrote: >> >>> I was able to write a very short C++ function using the Rcp

[Rcpp-devel] Segfault in R-devel CMD check Rcpp

2011-04-19 Thread Douglas Bates
Rcpp from SVN version 3004 is segfaulting on me in the unit tests at test.sugar.asvector Executing test function test.sugar.asvector ... *** caught segfault *** address 0x3, cause 'memory not mapped' Traceback: 1: .Primitive(".Call")(, x, y, z) 2: fx(1:4, 1:5, diag(1:5)) 3: func() 4: system

Re: [Rcpp-devel] Segfault in R-devel CMD check Rcpp

2011-04-19 Thread Douglas Bates
Sorry - I misspoke. The segfault was with R-2.13.0, the Ubuntu maverick amd_64 build. On Tue, Apr 19, 2011 at 12:55 PM, Douglas Bates wrote: > Rcpp from SVN version 3004 is segfaulting on me in the unit tests at > test.sugar.asvector > > Executing test function test.su

[Rcpp-devel] Unable to install RcppArmadillo from CRAN or from SVN archive on Ubuntu 10.10

2011-04-28 Thread Douglas Bates
I have been facing this problem for months now and I still don't know why other users of Ubuntu 10.10 using $ g++ --version g++ (Ubuntu/Linaro 4.4.4-14ubuntu5) 4.4.5 Copyright (C) 2010 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warrant

Re: [Rcpp-devel] Unable to install RcppArmadillo from CRAN or from SVN archive on Ubuntu 10.10

2011-04-28 Thread Douglas Bates
cil point breaking. On Thu, Apr 28, 2011 at 2:53 PM, Douglas Bates wrote: > I have been facing this problem for months now and I still don't know > why other users of Ubuntu 10.10 using > > $ g++ --version > g++ (Ubuntu/Linaro 4.4.4-14ubuntu5) 4.4.5 > Copyright (C) 2010 Free

Re: [Rcpp-devel] Unable to install RcppArmadillo from CRAN or from SVN archive on Ubuntu 10.10

2011-04-28 Thread Douglas Bates
iddle of our Rcpp workshop so this is timely :) > > On 28 April 2011 at 14:53, Douglas Bates wrote: > | I have been facing this problem for months now and I still don't know > | why other users of Ubuntu 10.10 using > | > | $ g++ --version > | g++ (Ubuntu/Linaro 4.4.4-1

Re: [Rcpp-devel] Unable to install RcppArmadillo from CRAN or from SVN archive on Ubuntu 10.10

2011-04-28 Thread Douglas Bates
On Thu, Apr 28, 2011 at 3:26 PM, Douglas Bates wrote: > I just realized what is probably happening.  I have the Ubuntu > armadillo package installed and that version of the header files may > be being picked up ahead of the version in the package. Oops. Scratch that theory. I don&#

Re: [Rcpp-devel] Unable to install RcppArmadillo from CRAN or from SVN archive on Ubuntu 10.10

2011-04-29 Thread Douglas Bates
Yesterday I upgraded to Ubuntu 11.04 for which the default g++ version is 4.5.2 I rebuilt R-devel and R-patched from the sources and things changed -- R-devel CMD check Rcpp now fails at a different point. This time it doesn't segfault but it does produce results that are different from the refer

Re: [Rcpp-devel] Unable to install RcppArmadillo from CRAN or from SVN archive on Ubuntu 10.10

2011-04-29 Thread Douglas Bates
OK, this is bizarre. I am able to install the RcppArmadillo package on my current setup provided that I turn on optimization in the call to g++ to compile RcppArmadillo.cpp. The only difference between the following two calls is the -O3 flag. (I haven't tried other levels of optimization yet but

Re: [Rcpp-devel] Unable to install RcppArmadillo from CRAN or from SVN archive on Ubuntu 10.10

2011-04-29 Thread Douglas Bates
And I can get past R CMD check Rcpp if I include -O3 in CXXFLAGS. On Fri, Apr 29, 2011 at 11:59 AM, Douglas Bates wrote: > OK, this is bizarre.  I am able to install the RcppArmadillo package > on my current setup provided that I turn on optimization in the call > to g++ t

[Rcpp-devel] Deep copy of a NumericVector, IntegerVector, etc. without using clone

2011-05-01 Thread Douglas Bates
I'm working on translating Tim Davis's CSparse library of C functions into templated C++ classes. The purpose is to allow spare matrix manipulation both using Rcpp objects and using other types of vector objects, such as std::vector. The templates are in terms of the vector objects. The basic re

Re: [Rcpp-devel] Rcpp equivalent of sample()?

2011-05-14 Thread Douglas Bates
You can check what is done in R itself in the R sources but I imagine that it uses a uniform random variate converted to an integer through the cumulative probabilities. The good news is that it is easy to create the cumulative weights with the std::accumulate function. On May 14, 2011 4:12 PM, "Ch

Re: [Rcpp-devel] Re-using C++ code from a package with modules and defining linker flags using Rscript

2011-05-15 Thread Douglas Bates
On May 15, 2011 5:17 PM, "Dirk Eddelbuettel" wrote: > > > Hi Jelmer, > > On 15 May 2011 at 21:42, Jelmer Ypma wrote: > | Dear all, > | > | This is a question about recommended ways of linking C++ code in an R > | package to C++ code defined in other R packages (using Rcpp 0.9.4.1 > > Well, you see

Re: [Rcpp-devel] Create and access several instances of a C++ class from R

2011-05-18 Thread Douglas Bates
On May 18, 2011 2:53 AM, wrote: > > Hello Dirk > > That was exactly the trick! Thanks a lot! Our class and code work so far, but it may take more time to debug or find bad design. Perhaps we will be back with more detailed questions. Anyway, one question already emerged. When librarying the class,

Re: [Rcpp-devel] R CMD BATCH - segfault (was: Create and access several instances of a C++ class from R)

2011-05-20 Thread Douglas Bates
On Fri, May 20, 2011 at 5:01 AM, wrote: > On 18.05.2011, at 15:17, Douglas Bates wrote: > >> On May 18, 2011 2:53 AM, wrote: >> >>> [...] >>> >>> When librarying the class, assigning an object, do some calculations, >>> whatever -- every

[Rcpp-devel] Constructor for templated Rcpp::Matrix class from Rcpp::Dimension fails

2011-06-01 Thread Douglas Bates
I am developing classes for sparse matrices with an Rcpp interface that includes Rcpp::Dimension dim() const {return Rcpp::Dimension(nr(), nc());} Rcpp::NumericMatrix asmatrix() const; The implementation of the asmatrix method begins with Rcpp::NumericMatrix ans(dim(

[Rcpp-devel] Create an instance of a reference class for a C++ class exported as a module from within C++?

2011-06-02 Thread Douglas Bates
Sorry for the long subject line but I hope it describes what I want to do. I have a C++ class, dgTMatrix, that is exported in a module definition. RCPP_MODULE(RcppSp) { ... class_("dgCMatrix") ... ; } Many of the methods for this class return other members of this class. Can I creat

Re: [Rcpp-devel] fun(Times) with STL

2011-06-04 Thread Douglas Bates
On Sat, Jun 4, 2011 at 11:08 AM, Silkworth,David J. wrote: > I ran into this yesterday as I needed to get the position of the least time > value in a small Que of times that I had extracted from a more complex > structure.   I ended up with this problem during a separate work-around, > which is a

Re: [Rcpp-devel] fun(Times) with STL

2011-06-04 Thread Douglas Bates
On Sat, Jun 4, 2011 at 11:26 AM, Douglas Bates wrote: > On Sat, Jun 4, 2011 at 11:08 AM, Silkworth,David J. > wrote: >> I ran into this yesterday as I needed to get the position of the least time >> value in a small Que of times that I had extracted from a more complex >>

[Rcpp-devel] Strange compiler error when using boost uBLAS on Ubuntu 11.04

2011-06-04 Thread Douglas Bates
With > sessionInfo() R version 2.14.0 Under development (unstable) (2011-05-26 r55995) Platform: x86_64-unknown-linux-gnu (64-bit) locale: [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C [3] LC_TIME=en_US.UTF-8LC_COLLATE=en_US.UTF-8 [5] LC_MONETARY=en_US.UTF-8LC_MESSAGES=en_US.UTF-8 [

Re: [Rcpp-devel] fun(Times) with STL

2011-06-04 Thread Douglas Bates
A thinko on my part. Remove the '*' in front of the std::min_element. On Sat, Jun 4, 2011 at 12:52 PM, Silkworth,David J. wrote: > Many thanks, Doug, I feel so-o-o close, but the revised example does not > compile. > I have taken the liberty to condense our discussion a little here. > dou

Re: [Rcpp-devel] RcppArmadillo inv() depends on Lapack, zgetri_ not available on CRAN / R-forge?

2011-06-07 Thread Douglas Bates
On Jun 6, 2011 4:17 AM, "baptiste auguie" wrote: > > Thank you for the explanations below. > > On 5 June 2011 10:40, Dirk Eddelbuettel wrote: > > > > On 5 June 2011 at 10:12, baptiste auguie wrote: > > | Hi Dirk and all, > > | > > | On 4 June 2011 12:04, Dirk Eddelbuettel wrote: > > | > > > | >

  1   2   3   4   5   >