[Rd] avoiding a needless function evaluation in optimize() (PR#9523)

2007-02-22 Thread j . j . goeman
Full_Name: Jelle Goeman
Version: 2.4.0
OS: windows XP
Submission from: (NULL) (145.88.209.33)


 Hi,

I like to use optimize() to optimize functions whose evaluation is costly in
terms of computation time. The Brent algorithm which is implemented in optimize
was designed to optimize a function with as few function evaluations as
possible. Therefore it bothers me that optimize() always evaluates the function
twice at the optimal value. This can be seen for example by saying:

square <- function(x) {
  print(x)
  x*x
}
opt <- optimize(square, c(-5,1), tol=0.1)

Looking at the code of optimize(), I see that the extra function evaluation
comes when optimize returns

list(minimum = val, objective = f(val, ...))

f(val, ...) is calculated, but f(val, ...) has already been calculated at some
point during the algorithm.

Would it be possible to let optimize() store its previous function evaluations
to avoid this unnecessary function evaluation? 

Kind regards,

Jelle

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] heatmap without dendrogams (PR#13512)

2009-02-09 Thread j . j . goeman
Full_Name: Jelle Goeman
Version: 2.8.1
OS: Win XP
Submission from: (NULL) (87.212.67.197)


I get the following error message when I try to make a heatmap (package stats),
without the associated dendrograms.

X <- matrix(rnorm(200),20,10)
XX <- crossprod(X)
heatmap(XX, Rowv= NA, revC=TRUE)
Error in rev(ddr) : object "ddr" not found
heatmap(XX, Rowv= NA, sym=TRUE)
Error in heatmap(XX, Rowv = NA, sym = TRUE) : object "ddr" not found
 
According to the help file, this should work; indeed it does if I set revC or
sym to FALSE. Seems like ddr should be initialized to something like 1:ncol(X)
for the no-dendrogram case.

Kind regards,

Jelle

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel