[Lme4-commits] r1476 - in pkg/lme4Eigen: R src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Dec 15 22:08:38 CET 2011


Author: dmbates
Date: 2011-12-15 22:08:37 +0100 (Thu, 15 Dec 2011)
New Revision: 1476

Modified:
   pkg/lme4Eigen/R/AllClass.R
   pkg/lme4Eigen/src/optimizer.h
Log:
Added a reverse-communication golden search algorithm class


Modified: pkg/lme4Eigen/R/AllClass.R
===================================================================
--- pkg/lme4Eigen/R/AllClass.R	2011-12-12 22:16:23 UTC (rev 1475)
+++ pkg/lme4Eigen/R/AllClass.R	2011-12-15 21:08:37 UTC (rev 1476)
@@ -421,6 +421,42 @@
                      })
                 )
 
+golden <-
+    setRefClass("golden", # Reverse communication implementation of Golden Search
+                fields =
+                list(
+                     Ptr     = "externalptr",
+                     lowerbd = "numeric",
+                     upperbd = "numeric"
+                     ),
+                methods =
+                list(
+                     initialize = function(lower, upper, ...) {
+                         stopifnot(length(lower <- as.numeric(lower)) == 1L,
+                                   length(upper <- as.numeric(upper)) == 1L,
+                                   lower > -Inf,
+                                   upper < Inf,
+                                   lower < upper)
+                         lowerbd <<- lower
+                         upperbd <<- upper
+                         Ptr <<- .Call(golden_Create, lower, upper)
+                     },
+                     ptr        =  function() {
+                         if (length(lowerbd)) 
+                             if (.Call(isNullExtPtr, Ptr))
+                                 Ptr <<- .Call(golden_Create, lowerbd, upperbd)
+                         Ptr
+                     },
+                     newf       = function(value) {
+                         stopifnot(length(value <- as.numeric(value)) == 1L)
+                         .Call(golden_newf, ptr(), value)
+                     },
+                     value      = function() .Call(golden_value, ptr()),
+                     xeval      = function() .Call(golden_xeval, ptr()),
+                     xpos       = function() .Call(golden_xpos, ptr())
+                     )
+            )
+
 setClass("merMod",
          representation(Gp      = "integer",
                         call    = "call",

Modified: pkg/lme4Eigen/src/optimizer.h
===================================================================
--- pkg/lme4Eigen/src/optimizer.h	2011-12-12 22:16:23 UTC (rev 1475)
+++ pkg/lme4Eigen/src/optimizer.h	2011-12-15 21:08:37 UTC (rev 1476)
@@ -111,14 +111,14 @@
 	const VectorXd&    lb() const {return d_lb;}
 	const VectorXd&    ub() const {return d_ub;}
 	const VectorXd&  vals() const {return d_vals;}
-	const VectorXd&     x() const {return d_x;}
 	const VectorXd& xstep() const {return d_xstep;}
 	const VectorXd& xeval() const {return d_xeval;}
+	const VectorXd&  xpos() const {return d_x;}
 	Index              ih() const {return d_ih;}
 	Index              il() const {return d_il;}
 	Index           evals() const {return d_stop.ev();}
 
-	Scalar           minf() const {return d_minf;}
+	Scalar          value() const {return d_minf;}
 	nm_status        newf(const Scalar&);
     };
 



More information about the Lme4-commits mailing list