/usr/lib/R/site-library/matrixStats/benchmarking/allocMatrix.md.rsp is in r-cran-matrixstats 0.14.2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | <%@include file="includes/setup.md.rsp"%>
<%@string fcnname="allocMatrix"%>
<% fcnname <- "<%@string name="fcnname"%>" %>
<%@meta title="${fcnname}() benchmarks"%>
<%@meta author="Henrik Bengtsson"%>
<%@meta date="2014-11-09"%>
<%@include file="${header}"%>
# <%@meta name="title"%>
This report benchmark the performance of <%=fcnname%>() against alternative methods.
## Alternative methods
* matrix()
* matrix() special trick for NA
where
```r
<%=withCapture({
allocMatrix_R <- function(nrow, ncol, value=NA) {
if (is.na(value) && !is.nan(value)) {
matrix(data=value[c()], nrow=nrow, ncol=ncol)
} else {
matrix(data=value, nrow=nrow, ncol=ncol)
}
} # allocMatrix_R()
})%>
```
<% for (mode in c("integer", "double")) { %>
## Data type "<%=mode%>"
### Data
```r
<%=withCapture({
<%@include file="R/random-matrices.R"%>
data <- rmatrices(mode=mode)
values <- list(zero=0, one=1, "NA"=NA_real_)
if (mode != "double")
values <- lapply(values, FUN=function(x) { storage.mode(x) <- mode; x })
})%>
```
### Results
<% for (ii in seq_along(data)) { %>
<%
dataLabel <- names(data)[ii]
x <- data[[dataLabel]]
gc()
%>
### <%=dataLabel%> matrix
<% for (value in values) { %>
<%
valueLabel <- as.character(value)
mprintf("%s: %s, value=%s\n", mode, dataLabel, valueLabel)
%>
```r
<%=withCapture({
dim <- dim(data[[.dataLabel.]])
nrow <- dim[1L]
ncol <- dim[2L]
str(value)
})%>
```
<% gc() %>
```r
<%=withCapture({
stats <- microbenchmark(
"allocMatrix" = allocMatrix(nrow=nrow, ncol=ncol, value=value),
"matrix" = matrix(data=value, nrow=nrow, ncol=ncol),
"allocMatrix_R" = allocMatrix_R(nrow=nrow, ncol=ncol, value=value),
unit = "ms"
)
})%>
```
<% benchmarkResults(stats, tags=c(mode, dataLabel, valueLabel)) %>
<% } # for (value in values) %>
<% } # for (ii ...) %>
<% } # for (mode ...) %>
<%@include file="${footer}"%>
<%---------------------------------------------------------------------------
HISTORY:
2014-11-01
o Created.
---------------------------------------------------------------------------%>
|