Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/multicore B4 #64

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
d6b5f36
Infrastructure for pthread processing
Dongcan-Jiang Jul 30, 2015
8c10b69
rowCounts.c: pthread processing
Dongcan-Jiang Jul 31, 2015
67328b3
colCounts.c: pthread processing
Dongcan-Jiang Jul 31, 2015
23b2740
rowCumMinMaxs.c: pthread processing
Dongcan-Jiang Aug 1, 2015
644a24f
rowCumprods.c: pthread processing
Dongcan-Jiang Aug 1, 2015
39187af
rowCumsums.c: pthread processing
Dongcan-Jiang Aug 1, 2015
a0437c1
use larger dataset to make improvement more visible
Dongcan-Jiang Aug 1, 2015
3d8a236
make *Counts consistent with others
Dongcan-Jiang Aug 1, 2015
cc6d2ef
Infrastructure for pthread vector processing
Dongcan-Jiang Aug 2, 2015
fbc2da1
rowLogSumExp.c: pthread processing
Dongcan-Jiang Aug 2, 2015
9e55174
make rowDiff tests more sufficient
Dongcan-Jiang Aug 2, 2015
fe756b7
rowDiffs.c: pthread processing
Dongcan-Jiang Aug 2, 2015
af9ccce
rowRanks.c: pthread processing
Dongcan-Jiang Aug 3, 2015
584886e
multiply nrow_ans instead of nrows to make it more readable
Dongcan-Jiang Aug 3, 2015
55b5ca9
fix warning of 'warn' variable
Dongcan-Jiang Aug 3, 2015
b96c07b
validateIndices with checking NA
Dongcan-Jiang Aug 9, 2015
0843494
rowOrderStats.c: pthread processing
Dongcan-Jiang Aug 9, 2015
4e359c8
rowRanges.c: pthread processing
Dongcan-Jiang Aug 10, 2015
746ec42
colOrderStats.c: pthread processing
Dongcan-Jiang Aug 12, 2015
893ef72
colRanges.c: pthread processing
Dongcan-Jiang Aug 12, 2015
bf0c93a
rowVars.c: pthread processing
Dongcan-Jiang Aug 12, 2015
1fc1478
rowMedians.c: pthread processing
Dongcan-Jiang Aug 12, 2015
5dbadec
rowMads.c: pthread processing
Dongcan-Jiang Aug 12, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions R/rowCounts.R
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ rowCounts <- function(x, rows=NULL, cols=NULL, value=TRUE, na.rm=FALSE, dim.=dim
if (is.numeric(x) || is.logical(x)) {
na.rm <- as.logical(na.rm)
hasNAs <- TRUE
counts <- .Call("rowCounts", x, dim., rows, cols, value, 2L, na.rm, hasNAs, PACKAGE="matrixStats")
counts <- .Call("rowCounts", x, dim., rows, cols, value, 2L, na.rm, hasNAs, mc.cores, PACKAGE="matrixStats")
} else {
if (is.vector(x)) dim(x) <- dim.

Expand Down Expand Up @@ -130,7 +130,7 @@ colCounts <- function(x, rows=NULL, cols=NULL, value=TRUE, na.rm=FALSE, dim.=dim
if (is.numeric(x) || is.logical(x)) {
na.rm <- as.logical(na.rm)
hasNAs <- TRUE
counts <- .Call("colCounts", x, dim., rows, cols, value, 2L, na.rm, hasNAs, PACKAGE="matrixStats")
counts <- .Call("colCounts", x, dim., rows, cols, value, 2L, na.rm, hasNAs, mc.cores, PACKAGE="matrixStats")
} else {
if (is.vector(x)) dim(x) <- dim.

Expand Down Expand Up @@ -193,7 +193,7 @@ rowAlls <- function(x, rows=NULL, cols=NULL, value=TRUE, na.rm=FALSE, dim.=dim(x
if (is.numeric(x) || is.logical(x)) {
na.rm <- as.logical(na.rm)
hasNAs <- TRUE
counts <- .Call("rowCounts", x, dim., rows, cols, value, 0L, na.rm, hasNAs, PACKAGE="matrixStats")
counts <- .Call("rowCounts", x, dim., rows, cols, value, 0L, na.rm, hasNAs, mc.cores, PACKAGE="matrixStats")
as.logical(counts)
} else {
if (is.vector(x)) dim(x) <- dim.
Expand All @@ -216,7 +216,7 @@ colAlls <- function(x, rows=NULL, cols=NULL, value=TRUE, na.rm=FALSE, dim.=dim(x
if (is.numeric(x) || is.logical(x)) {
na.rm <- as.logical(na.rm)
hasNAs <- TRUE
counts <- .Call("colCounts", x, dim., rows, cols, value, 0L, na.rm, hasNAs, PACKAGE="matrixStats")
counts <- .Call("colCounts", x, dim., rows, cols, value, 0L, na.rm, hasNAs, mc.cores, PACKAGE="matrixStats")
as.logical(counts)
} else {
if (is.vector(x)) dim(x) <- dim.
Expand Down Expand Up @@ -260,7 +260,7 @@ rowAnys <- function(x, rows=NULL, cols=NULL, value=TRUE, na.rm=FALSE, dim.=dim(x
if (is.numeric(x) || is.logical(x)) {
na.rm <- as.logical(na.rm)
hasNAs <- TRUE
counts <- .Call("rowCounts", x, dim., rows, cols, value, 1L, na.rm, hasNAs, PACKAGE="matrixStats")
counts <- .Call("rowCounts", x, dim., rows, cols, value, 1L, na.rm, hasNAs, mc.cores, PACKAGE="matrixStats")
as.logical(counts)
} else {
if (is.vector(x)) dim(x) <- dim.
Expand All @@ -283,7 +283,7 @@ colAnys <- function(x, rows=NULL, cols=NULL, value=TRUE, na.rm=FALSE, dim.=dim(x
if (is.numeric(x) || is.logical(x)) {
na.rm <- as.logical(na.rm)
hasNAs <- TRUE
counts <- .Call("colCounts", x, dim., rows, cols, value, 1L, na.rm, hasNAs, PACKAGE="matrixStats")
counts <- .Call("colCounts", x, dim., rows, cols, value, 1L, na.rm, hasNAs, mc.cores, PACKAGE="matrixStats")
as.logical(counts)
} else {
if (is.vector(x)) dim(x) <- dim.
Expand Down
16 changes: 8 additions & 8 deletions R/rowCumsums.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,44 +56,44 @@
#*/###########################################################################
rowCumsums <- function(x, rows=NULL, cols=NULL, dim.=dim(x), mc.cores=1L, ...) {
dim <- as.integer(dim.);
.Call("rowCumsums", x, dim, rows, cols, TRUE, PACKAGE="matrixStats")
.Call("rowCumsums", x, dim, rows, cols, TRUE, mc.cores, PACKAGE="matrixStats")
}

colCumsums <- function(x, rows=NULL, cols=NULL, dim.=dim(x), mc.cores=1L, ...) {
dim <- as.integer(dim.);
.Call("rowCumsums", x, dim, rows, cols, FALSE, PACKAGE="matrixStats")
.Call("rowCumsums", x, dim, rows, cols, FALSE, mc.cores, PACKAGE="matrixStats")
}


rowCumprods <- function(x, rows=NULL, cols=NULL, dim.=dim(x), mc.cores=1L, ...) {
dim <- as.integer(dim.);
.Call("rowCumprods", x, dim, rows, cols, TRUE, PACKAGE="matrixStats")
.Call("rowCumprods", x, dim, rows, cols, TRUE, mc.cores, PACKAGE="matrixStats")
}

colCumprods <- function(x, rows=NULL, cols=NULL, dim.=dim(x), mc.cores=1L, ...) {
dim <- as.integer(dim.);
.Call("rowCumprods", x, dim, rows, cols, FALSE, PACKAGE="matrixStats")
.Call("rowCumprods", x, dim, rows, cols, FALSE, mc.cores, PACKAGE="matrixStats")
}


rowCummins <- function(x, rows=NULL, cols=NULL, dim.=dim(x), mc.cores=1L, ...) {
dim <- as.integer(dim.);
.Call("rowCummins", x, dim, rows, cols, TRUE, PACKAGE="matrixStats")
.Call("rowCummins", x, dim, rows, cols, TRUE, mc.cores, PACKAGE="matrixStats")
}

colCummins <- function(x, rows=NULL, cols=NULL, dim.=dim(x), mc.cores=1L, ...) {
dim <- as.integer(dim.);
.Call("rowCummins", x, dim, rows, cols, FALSE, PACKAGE="matrixStats")
.Call("rowCummins", x, dim, rows, cols, FALSE, mc.cores, PACKAGE="matrixStats")
}

rowCummaxs <- function(x, rows=NULL, cols=NULL, dim.=dim(x), mc.cores=1L, ...) {
dim <- as.integer(dim.);
.Call("rowCummaxs", x, dim, rows, cols, TRUE, PACKAGE="matrixStats")
.Call("rowCummaxs", x, dim, rows, cols, TRUE, mc.cores, PACKAGE="matrixStats")
}

colCummaxs <- function(x, rows=NULL, cols=NULL, dim.=dim(x), mc.cores=1L, ...) {
dim <- as.integer(dim.);
.Call("rowCummaxs", x, dim, rows, cols, FALSE, PACKAGE="matrixStats")
.Call("rowCummaxs", x, dim, rows, cols, FALSE, mc.cores, PACKAGE="matrixStats")
}


Expand Down
4 changes: 2 additions & 2 deletions R/rowDiffs.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@
# @keyword univar
#*/###########################################################################
rowDiffs <- function(x, rows=NULL, cols=NULL, lag=1L, differences=1L, mc.cores=1L, ...) {
.Call("rowDiffs", x, dim(x), rows, cols, as.integer(lag), as.integer(differences), TRUE, PACKAGE="matrixStats")
.Call("rowDiffs", x, dim(x), rows, cols, as.integer(lag), as.integer(differences), TRUE, mc.cores, PACKAGE="matrixStats")
}

colDiffs <- function(x, rows=NULL, cols=NULL, lag=1L, differences=1L, mc.cores=1L, ...) {
.Call("rowDiffs", x, dim(x), rows, cols, as.integer(lag), as.integer(differences), FALSE, PACKAGE="matrixStats")
.Call("rowDiffs", x, dim(x), rows, cols, as.integer(lag), as.integer(differences), FALSE, mc.cores, PACKAGE="matrixStats")
}


Expand Down
4 changes: 2 additions & 2 deletions R/rowLogSumExps.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ rowLogSumExps <- function(lx, rows=NULL, cols=NULL, na.rm=FALSE, dim.=dim(lx), m
hasNA <- TRUE;
res <- .Call("rowLogSumExps",
lx, dim., rows, cols,
as.logical(na.rm), as.logical(hasNA), TRUE,
as.logical(na.rm), as.logical(hasNA), TRUE, mc.cores,
PACKAGE="matrixStats");

# Preserve names
Expand All @@ -71,7 +71,7 @@ colLogSumExps <- function(lx, rows=NULL, cols=NULL, na.rm=FALSE, dim.=dim(lx), m
hasNA <- TRUE;
res <- .Call("rowLogSumExps",
lx, dim., rows, cols,
as.logical(na.rm), as.logical(hasNA), FALSE,
as.logical(na.rm), as.logical(hasNA), FALSE, mc.cores,
PACKAGE="matrixStats");

# Preserve names
Expand Down
8 changes: 4 additions & 4 deletions R/rowMads.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ rowMads <- function(x, rows=NULL, cols=NULL, center=NULL, constant=1.4826, na.rm
na.rm <- as.logical(na.rm)
constant = as.numeric(constant)
hasNAs <- TRUE
x <- .Call("rowMads", x, dim., rows, cols, constant, na.rm, hasNAs, TRUE, PACKAGE="matrixStats")
x <- .Call("rowMads", x, dim., rows, cols, constant, na.rm, hasNAs, TRUE, mc.cores, PACKAGE="matrixStats")
} else {
# Apply subset on 'x'
if (is.vector(x)) dim(x) <- dim.
Expand All @@ -27,7 +27,7 @@ rowMads <- function(x, rows=NULL, cols=NULL, center=NULL, constant=1.4826, na.rm
x <- x - center
if (is.null(dim(x))) dim(x) <- dim. # prevent from dim dropping
x <- abs(x)
x <- rowMedians(x, na.rm=na.rm, ...)
x <- rowMedians(x, na.rm=na.rm, mc.cores=mc.cores, ...)
x <- constant*x
}
x
Expand All @@ -48,7 +48,7 @@ colMads <- function(x, rows=NULL, cols=NULL, center=NULL, constant=1.4826, na.rm
na.rm <- as.logical(na.rm)
constant = as.numeric(constant)
hasNAs <- TRUE
x <- .Call("rowMads", x, dim., rows, cols, constant, na.rm, hasNAs, FALSE, PACKAGE="matrixStats")
x <- .Call("rowMads", x, dim., rows, cols, constant, na.rm, hasNAs, FALSE, mc.cores, PACKAGE="matrixStats")
} else {
# Apply subset on 'x'
if (is.vector(x)) dim(x) <- dim.
Expand All @@ -67,7 +67,7 @@ colMads <- function(x, rows=NULL, cols=NULL, center=NULL, constant=1.4826, na.rm
## FAST:
x <- t_tx_OP_y(x, center, OP="-", na.rm=FALSE)
x <- abs(x)
x <- colMedians(x, na.rm=na.rm, ...)
x <- colMedians(x, na.rm=na.rm, mc.cores=mc.cores, ...)
x <- constant*x
}
x
Expand Down
4 changes: 2 additions & 2 deletions R/rowMedians.S4.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ setMethod("rowMedians", signature(x="matrix"), function(x, rows=NULL, cols=NULL,
na.rm <- as.logical(na.rm);
hasNAs <- TRUE; # Add as an argument? /2007-08-24

.Call("rowMedians", x, dim., rows, cols, na.rm, hasNAs, TRUE, PACKAGE="matrixStats");
.Call("rowMedians", x, dim., rows, cols, na.rm, hasNAs, TRUE, mc.cores, PACKAGE="matrixStats");
})


Expand All @@ -76,7 +76,7 @@ setMethod("colMedians", signature(x="matrix"), function(x, rows=NULL, cols=NULL,
na.rm <- as.logical(na.rm);
hasNAs <- TRUE; # Add as an argument? /2007-08-24

.Call("rowMedians", x, dim., rows, cols, na.rm, hasNAs, FALSE, PACKAGE="matrixStats");
.Call("rowMedians", x, dim., rows, cols, na.rm, hasNAs, FALSE, mc.cores, PACKAGE="matrixStats");
})


Expand Down
4 changes: 2 additions & 2 deletions R/rowOrderStats.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ rowOrderStats <- function(x, rows=NULL, cols=NULL, which, dim.=dim(x), mc.cores=
}

which <- as.integer(which)
.Call("rowOrderStats", x, dim., rows, cols, which, PACKAGE="matrixStats");
.Call("rowOrderStats", x, dim., rows, cols, which, mc.cores, PACKAGE="matrixStats");
}


Expand All @@ -80,7 +80,7 @@ colOrderStats <- function(x, rows=NULL, cols=NULL, which, dim.=dim(x), mc.cores=
}

which <- as.integer(which)
.Call("colOrderStats", x, dim., rows, cols, which, PACKAGE="matrixStats");
.Call("colOrderStats", x, dim., rows, cols, which, mc.cores, PACKAGE="matrixStats");
}


Expand Down
12 changes: 6 additions & 6 deletions R/rowRanges.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,38 +57,38 @@
rowRanges <- function(x, rows=NULL, cols=NULL, na.rm=FALSE, dim.=dim(x), mc.cores=1L, ...) {
dim. <- as.integer(dim.)
na.rm <- as.logical(na.rm)
.Call("rowRanges", x, dim., rows, cols, 2L, na.rm, TRUE, PACKAGE="matrixStats")
.Call("rowRanges", x, dim., rows, cols, 2L, na.rm, TRUE, mc.cores, PACKAGE="matrixStats")
}

rowMins <- function(x, rows=NULL, cols=NULL, na.rm=FALSE, dim.=dim(x), mc.cores=1L, ...) {
dim. <- as.integer(dim.)
na.rm <- as.logical(na.rm)
.Call("rowRanges", x, dim., rows, cols, 0L, na.rm, TRUE, PACKAGE="matrixStats")
.Call("rowRanges", x, dim., rows, cols, 0L, na.rm, TRUE, mc.cores, PACKAGE="matrixStats")
}

rowMaxs <- function(x, rows=NULL, cols=NULL, na.rm=FALSE, dim.=dim(x), mc.cores=1L, ...) {
dim. <- as.integer(dim.)
na.rm <- as.logical(na.rm)
.Call("rowRanges", x, dim., rows, cols, 1L, na.rm, TRUE, PACKAGE="matrixStats")
.Call("rowRanges", x, dim., rows, cols, 1L, na.rm, TRUE, mc.cores, PACKAGE="matrixStats")
}


colRanges <- function(x, rows=NULL, cols=NULL, na.rm=FALSE, dim.=dim(x), mc.cores=1L, ...) {
dim. <- as.integer(dim.)
na.rm <- as.logical(na.rm)
.Call("colRanges", x, dim., rows, cols, 2L, na.rm, TRUE, PACKAGE="matrixStats")
.Call("colRanges", x, dim., rows, cols, 2L, na.rm, TRUE, mc.cores, PACKAGE="matrixStats")
}

colMins <- function(x, rows=NULL, cols=NULL, na.rm=FALSE, dim.=dim(x), mc.cores=1L, ...) {
dim. <- as.integer(dim.)
na.rm <- as.logical(na.rm)
.Call("colRanges", x, dim., rows, cols, 0L, na.rm, TRUE, PACKAGE="matrixStats")
.Call("colRanges", x, dim., rows, cols, 0L, na.rm, TRUE, mc.cores, PACKAGE="matrixStats")
}

colMaxs <- function(x, rows=NULL, cols=NULL, na.rm=FALSE, dim.=dim(x), mc.cores=1L, ...) {
dim. <- as.integer(dim.)
na.rm <- as.logical(na.rm)
.Call("colRanges", x, dim., rows, cols, 1L, na.rm, TRUE, PACKAGE="matrixStats")
.Call("colRanges", x, dim., rows, cols, 1L, na.rm, TRUE, mc.cores, PACKAGE="matrixStats")
}


Expand Down
4 changes: 2 additions & 2 deletions R/rowRanks.R
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ rowRanks <- function(x, rows=NULL, cols=NULL, ties.method=c("max", "average", "m

dim. <- as.integer(dim.)
# byrow=TRUE
.Call("rowRanksWithTies", x, dim., rows, cols, tiesMethod, TRUE, PACKAGE="matrixStats")
.Call("rowRanksWithTies", x, dim., rows, cols, tiesMethod, TRUE, mc.cores, PACKAGE="matrixStats")
}


Expand All @@ -133,7 +133,7 @@ colRanks <- function(x, rows=NULL, cols=NULL, ties.method=c("max", "average", "m

dim. <- as.integer(dim.)
# byrow=FALSE
y <- .Call("rowRanksWithTies", x, dim., rows, cols, tiesMethod, FALSE, PACKAGE="matrixStats")
y <- .Call("rowRanksWithTies", x, dim., rows, cols, tiesMethod, FALSE, mc.cores, PACKAGE="matrixStats")
if (!preserveShape) y <- t(y)
y
}
Expand Down
4 changes: 2 additions & 2 deletions R/rowVars.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ rowVars <- function(x, rows=NULL, cols=NULL, na.rm=FALSE, center=NULL, dim.=dim(
if (is.null(center)) {
na.rm <- as.logical(na.rm)
hasNAs <- TRUE
sigma2 <- .Call("rowVars", x, dim., rows, cols, na.rm, hasNAs, TRUE, PACKAGE="matrixStats");
sigma2 <- .Call("rowVars", x, dim., rows, cols, na.rm, hasNAs, TRUE, mc.cores, PACKAGE="matrixStats");
return(sigma2)
}

Expand Down Expand Up @@ -112,7 +112,7 @@ colVars <- function(x, rows=NULL, cols=NULL, na.rm=FALSE, center=NULL, dim.=dim(
dim. <- as.integer(dim.)
na.rm <- as.logical(na.rm)
hasNAs <- TRUE
sigma2 <- .Call("rowVars", x, dim., rows, cols, na.rm, hasNAs, FALSE, PACKAGE="matrixStats");
sigma2 <- .Call("rowVars", x, dim., rows, cols, na.rm, hasNAs, FALSE, mc.cores, PACKAGE="matrixStats");
return(sigma2)
}

Expand Down
2 changes: 1 addition & 1 deletion inst/benchmarking/colRowCummins_parallel.md.rsp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ This report benchmark the performance of <%=colname%>() and <%=rowname%>() on mu
```r
<%=withCapture({
<%@include file="R/random-matrices.R"%>
data <- rmatrices(mode=mode)
data <- rmatrices(mode=mode, scale=20)
})%>
```

Expand Down
2 changes: 1 addition & 1 deletion inst/benchmarking/colRowCumprods_parallel.md.rsp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ This report benchmark the performance of <%=colname%>() and <%=rowname%>() on mu
```r
<%=withCapture({
<%@include file="R/random-matrices.R"%>
data <- rmatrices(mode=mode, range=c(-1,1))
data <- rmatrices(mode=mode, range=c(-1,1), scale=20)
})%>
```

Expand Down
2 changes: 1 addition & 1 deletion inst/benchmarking/colRowCumsums_parallel.md.rsp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ This report benchmark the performance of <%=colname%>() and <%=rowname%>() on mu
```r
<%=withCapture({
<%@include file="R/random-matrices.R"%>
data <- rmatrices(mode=mode)
data <- rmatrices(mode=mode, scale=20)
})%>
```

Expand Down
2 changes: 2 additions & 0 deletions src/Makevars
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PKG_CFLAGS=-pthread
PKG_LIBS=-pthread
25 changes: 16 additions & 9 deletions src/colCounts.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

#define METHOD colCounts
#define RETURN_TYPE void
#define ARGUMENTS_LIST X_C_TYPE *x, R_xlen_t nrow, R_xlen_t ncol, void *rows, R_xlen_t nrows, void *cols, R_xlen_t ncols, X_C_TYPE value, int what, int narm, int hasna, int *ans
#define ARGUMENTS_LIST X_C_TYPE *x, R_xlen_t nrow, R_xlen_t ncol, void *rows, R_xlen_t nrows, void *cols, R_xlen_t ncols, X_C_TYPE value, int what, int narm, int hasna, int *ans, int cores

#define X_TYPE 'i'
#include "templates-gen-matrix.h"
Expand All @@ -21,9 +21,9 @@
#include "templates-gen-matrix.h"


SEXP colCounts(SEXP x, SEXP dim, SEXP rows, SEXP cols, SEXP value, SEXP what, SEXP naRm, SEXP hasNA) {
SEXP colCounts(SEXP x, SEXP dim, SEXP rows, SEXP cols, SEXP value, SEXP what, SEXP naRm, SEXP hasNA, SEXP cores) {
SEXP ans;
int narm, hasna, what2;
int narm, hasna, what2, cores2;
R_xlen_t nrow, ncol;

/* Argument 'x' and 'dim': */
Expand All @@ -40,6 +40,8 @@ SEXP colCounts(SEXP x, SEXP dim, SEXP rows, SEXP cols, SEXP value, SEXP what, SE

/* Argument 'what': */
what2 = asInteger(what);
if (what2 < 0 || what2 > 2)
error("INTERNAL ERROR: Unknown value of 'what' for rowCounts: %d", what2);

/* Argument 'naRm': */
narm = asLogicalNoNA(naRm, "na.rm");
Expand All @@ -53,15 +55,18 @@ SEXP colCounts(SEXP x, SEXP dim, SEXP rows, SEXP cols, SEXP value, SEXP what, SE
void *crows = validateIndices(rows, nrow, 0, &nrows, &rowsType);
void *ccols = validateIndices(cols, ncol, 0, &ncols, &colsType);

/* Argument 'cores': */
cores2 = asInteger(cores);

/* R allocate an integer vector of length 'ncol' */
PROTECT(ans = allocVector(INTSXP, ncols));

if (isReal(x)) {
colCounts_Real[rowsType][colsType](REAL(x), nrow, ncol, crows, nrows, ccols, ncols, asReal(value), what2, narm, hasna, INTEGER(ans));
colCounts_Real[rowsType][colsType](REAL(x), nrow, ncol, crows, nrows, ccols, ncols, asReal(value), what2, narm, hasna, INTEGER(ans), cores2);
} else if (isInteger(x)) {
colCounts_Integer[rowsType][colsType](INTEGER(x), nrow, ncol, crows, nrows, ccols, ncols, asInteger(value), what2, narm, hasna, INTEGER(ans));
colCounts_Integer[rowsType][colsType](INTEGER(x), nrow, ncol, crows, nrows, ccols, ncols, asInteger(value), what2, narm, hasna, INTEGER(ans), cores2);
} else if (isLogical(x)) {
colCounts_Logical[rowsType][colsType](LOGICAL(x), nrow, ncol, crows, nrows, ccols, ncols, asLogical(value), what2, narm, hasna, INTEGER(ans));
colCounts_Logical[rowsType][colsType](LOGICAL(x), nrow, ncol, crows, nrows, ccols, ncols, asLogical(value), what2, narm, hasna, INTEGER(ans), cores2);
}

UNPROTECT(1);
Expand Down Expand Up @@ -105,11 +110,11 @@ SEXP count(SEXP x, SEXP idxs, SEXP value, SEXP what, SEXP naRm, SEXP hasNA) {
PROTECT(ans = allocVector(INTSXP, 1));

if (isReal(x)) {
colCounts_Real[rowsType][colsType](REAL(x), nx, 1, crows, nrows, ccols, ncols, asReal(value), what2, narm, hasna, INTEGER(ans));
colCounts_Real[rowsType][colsType](REAL(x), nx, 1, crows, nrows, ccols, ncols, asReal(value), what2, narm, hasna, INTEGER(ans), 1);
} else if (isInteger(x)) {
colCounts_Integer[rowsType][colsType](INTEGER(x), nx, 1, crows, nrows, ccols, ncols, asInteger(value), what2, narm, hasna, INTEGER(ans));
colCounts_Integer[rowsType][colsType](INTEGER(x), nx, 1, crows, nrows, ccols, ncols, asInteger(value), what2, narm, hasna, INTEGER(ans), 1);
} else if (isLogical(x)) {
colCounts_Logical[rowsType][colsType](LOGICAL(x), nx, 1, crows, nrows, ccols, ncols, asLogical(value), what2, narm, hasna, INTEGER(ans));
colCounts_Logical[rowsType][colsType](LOGICAL(x), nx, 1, crows, nrows, ccols, ncols, asLogical(value), what2, narm, hasna, INTEGER(ans), 1);
}

UNPROTECT(1);
Expand All @@ -120,6 +125,8 @@ SEXP count(SEXP x, SEXP idxs, SEXP value, SEXP what, SEXP naRm, SEXP hasNA) {

/***************************************************************************
HISTORY:
2015-07-31 [DJ]
o Pthread processing.
2015-04-21 [DJ]
o Supported subsetted computation.
2014-11-14 [HB]
Expand Down