Skip to content

Commit

Permalink
add core argument for parallelization
Browse files Browse the repository at this point in the history
  • Loading branch information
ManosPapadakis95 committed Jul 7, 2023
1 parent 36fdd77 commit 665065b
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 35 deletions.
18 changes: 9 additions & 9 deletions R/Quantile.R
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
#[export]
Quantile <- function(x, probs) {
.Call(Rfast2_Quantile, x, probs)
.Call(Rfast2_Quantile, x, probs)
}

#[export]
rowQuantile <- function(x, probs, parallel = FALSE) {
.Call(Rfast2_rowQuantile, x, probs, parallel)
rowQuantile <- function(x, probs, parallel = FALSE, cores = 0) {
.Call(Rfast2_rowQuantile, x, probs, parallel, cores)
}

#[export s3]
colQuantile.data.frame<-function(x, probs, parallel = FALSE) {
.Call(Rfast2_colQuantile, x, probs, parallel)
colQuantile.data.frame <- function(x, probs, parallel = FALSE, cores = 0) {
.Call(Rfast2_colQuantile, x, probs, parallel, cores)
}
#[export]
colQuantile<-function(x, probs, parallel = FALSE) {
UseMethod("colQuantile")
colQuantile <- function(x, probs, parallel = FALSE, cores = 0) {
UseMethod("colQuantile")
}
#[export s3]
colQuantile.matrix<-function(x, probs, parallel = FALSE) {
.Call(Rfast2_colQuantile, x, probs, parallel)
colQuantile.matrix <- function(x, probs, parallel = FALSE, cores = 0) {
.Call(Rfast2_colQuantile, x, probs, parallel, cores)
}
18 changes: 9 additions & 9 deletions R/trim.mean.R
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
#[export]
trim.mean <- function(x, a = 0.05) {
.Call(Rfast2_trimmean, x, a)
.Call(Rfast2_trimmean, x, a)
}

#[export]
rowTrimMean <- function(x, a = 0.05, parallel = FALSE) {
.Call(Rfast2_rowTrimMean, x, a, parallel)
rowTrimMean <- function(x, a = 0.05, parallel = FALSE, cores = 0) {
.Call(Rfast2_rowTrimMean, x, a, parallel, cores)
}

#[export]
colTrimMean <- function(x, a = 0.05, parallel = FALSE) {
UseMethod("colTrimMean")
colTrimMean <- function(x, a = 0.05, parallel = FALSE, cores = 0) {
UseMethod("colTrimMean")
}

#[export s3]
colTrimMean.matrix <- function(x, a = 0.05, parallel = FALSE) {
.Call(Rfast2_colTrimMean, x, a, parallel)
colTrimMean.matrix <- function(x, a = 0.05, parallel = FALSE, cores = 0) {
.Call(Rfast2_colTrimMean, x, a, parallel, cores)
}

#[export s3]
colTrimMean.data.frame <- function(x, a = 0.05, parallel = FALSE) {
.Call(Rfast2_colTrimMean, x, a, parallel)
colTrimMean.data.frame <- function(x, a = 0.05, parallel = FALSE, cores = 0) {
.Call(Rfast2_colTrimMean, x, a, parallel, cores)
}
17 changes: 9 additions & 8 deletions man/Quantile.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ Sample quantiles and col/row wise quantiles.
}

\usage{
colQuantile(x,probs,parallel=FALSE)
\method{colQuantile}{matrix}(x,probs,parallel=FALSE)
\method{colQuantile}{data.frame}(x,probs,parallel=FALSE)
rowQuantile(x,probs,parallel=FALSE)
colQuantile(x,probs,parallel=FALSE,cores=0)
\method{colQuantile}{matrix}(x,probs,parallel=FALSE,cores=0)
\method{colQuantile}{data.frame}(x,probs,parallel=FALSE,cores=0)
rowQuantile(x,probs,parallel=FALSE,cores=0)
Quantile(x,probs)
}

\arguments{
\item{x}{
Numeric vector whose sample quantiles are wanted. NA and NaN values are not allowed in numeric vectors.
For the col/row versions a numerical matrix.
For the col/row versions a numerical matrix or data.frame.
}
\item{probs}{
Numeric vector of probabilities with values in [0,1], not missing values.
Expand All @@ -32,6 +32,10 @@ Values up to 2e-14 outside that range are accepted and automatically moved to th
\item{parallel}{
Do you want to do it in parallel, for column - row major, in C++? TRUE or FALSE.
}
\item{cores}{
Number of cores to use for parallelism. Valid only when argument parallel is set to TRUE.
Default value is 0 and it means the maximum supported cores.
}
}

\details{
Expand All @@ -49,9 +53,6 @@ Manos Papadakis.
R implementation and documentation: Manos Papadakis \email{papadakm95@gmail.com}.
}
%\note{
%% ~~further notes~~
%}
\seealso{
\code{ \link{trim.mean} }
}
Expand Down
18 changes: 9 additions & 9 deletions man/trim.mean.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,26 @@ Trimmed mean.

\usage{
trim.mean(x, a = 0.05)
colTrimMean(x, a = 0.05,parallel=FALSE)
\method{colTrimMean}{matrix}(x,a = 0.05,parallel=FALSE)
\method{colTrimMean}{data.frame}(x,a = 0.05,parallel=FALSE)
rowTrimMean(x, a = 0.05,parallel=FALSE)
colTrimMean(x, a = 0.05,parallel=FALSE,cores=0)
\method{colTrimMean}{matrix}(x,a = 0.05,parallel=FALSE,cores=0)
\method{colTrimMean}{data.frame}(x,a = 0.05,parallel=FALSE,cores=0)
rowTrimMean(x, a = 0.05,parallel=FALSE,cores=0)
}

\arguments{
\item{x}{
A numerical vector or a numerical matrix.
A numerical vector or a numerical matrix or data.frame.
}
\item{a}{
A number in (0, 1), the proportion of data to trim.
}
\item{parallel}{
Run the algorithm parallel in C++.
}
\item{cores}{
Number of cores to use for parallelism. Valid only when argument parallel is set to TRUE.
Default value is 0 and it means the maximum supported cores.
}
}

\details{
Expand All @@ -51,10 +55,6 @@ Michail Tsagris and Manos Papadakis.
R implementation and documentation: Michail Tsagris \email{mtsagris@uoc.gr} and Manos Papadakis \email{papadakm95@gmail.com}.
}

%\note{
%% ~~further notes~~
%}

\seealso{
\code{ \link{Quantile}
}
Expand Down

0 comments on commit 665065b

Please sign in to comment.