David,

On 29 May 2011 at 18:02, Dirk Eddelbuettel wrote:
| I am a little stumped too. I also failed to get it to work. I will take
| another look later --- this may in fact be a bug.

It _was_ a bug and seemingly nobody but you ever tried rnlorm :)  

There was a silly typo bug inasmuch as the header guard used _norm_ not
_lnorm_ and with the other term already defined, this header file was never
included.  We also need a few more fixed making exp() explicitly call the C
math library one, and correcting a typo.  

If you are comfortable applying a diff, try this one from rev3038.

Cheers,  Dirk


Index: inst/include/Rcpp/stats/random/rlnorm.h
===================================================================
--- inst/include/Rcpp/stats/random/rlnorm.h     (revision 3029)
+++ inst/include/Rcpp/stats/random/rlnorm.h     (working copy)
@@ -19,8 +19,8 @@
 // You should have received a copy of the GNU General Public License
 // along with Rcpp.  If not, see <http://www.gnu.org/licenses/>.
 
-#ifndef Rcpp__stats__random_norm_h
-#define Rcpp__stats__random_norm_h
+#ifndef Rcpp__stats__random_lnorm_h
+#define Rcpp__stats__random_lnorm_h
 
 namespace Rcpp {
        namespace stats {
@@ -32,7 +32,7 @@
                                meanlog(meanlog_), sdlog(sdlog_) {}
        
                        inline double operator()() const {
-                               return exp( meanlog + sdlog * ::norm_rand() ) ;
+                               return ::exp( meanlog + sdlog * ::norm_rand() ) 
;
                        }
        
                private:
@@ -47,7 +47,7 @@
                                meanlog(meanlog_) {}
        
                        inline double operator()() const {
-                               return exp( meanlog + ::norm_rand() ) ;
+                               return ::exp( meanlog + ::norm_rand() ) ;
                        }
        
                private:
@@ -57,10 +57,10 @@
                class LNormGenerator_0 : public Generator<false,double> {
                public:
        
-                       LNormGenerator_1( ) {}
+                       LNormGenerator_0( ) {}
        
                        inline double operator()() const {
-                               return exp(::norm_rand() ) ;
+                               return ::exp(::norm_rand() ) ;
                        }
        
                } ;
@@ -75,7 +75,7 @@
                        // TODO: R also throws a warning in that case, should 
we ?
                        return NumericVector( n, R_NaN ) ;
                }  else if (sdlog == 0. || !R_FINITE(meanlog)){
-                       return NumericVector( n, exp( meanlog ) ) ;
+                       return NumericVector( n, ::exp( meanlog ) ) ;
                } else {
                        return NumericVector( n, stats::LNormGenerator( 
meanlog, sdlog ) ); 
                }

-- 
Gauss once played himself in a zero-sum game and won $50.
                      -- #11 at http://www.gaussfacts.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

Reply via email to