From 44faf0c7b126bb513c90f5f4bdc0cb197e1600cf Mon Sep 17 00:00:00 2001 From: Edzer Pebesma Date: Sat, 20 Jan 2018 00:41:34 +0100 Subject: [PATCH] fixes the valgrind error, #89 --- NAMESPACE | 3 --- R/arith.R | 58 +++++++++++++++++++++++++------------------------- man/matmult.Rd | 36 ------------------------------- 3 files changed, 29 insertions(+), 68 deletions(-) delete mode 100644 man/matmult.Rd diff --git a/NAMESPACE b/NAMESPACE index 0b7ccabf..88b88370 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,7 +1,5 @@ # Generated by roxygen2: do not edit by hand -S3method("%*%",default) -S3method("%*%",units) S3method("[",units) S3method("units<-",logical) S3method("units<-",numeric) @@ -40,7 +38,6 @@ S3method(summary,units) S3method(units,symbolic_units) S3method(units,units) S3method(weighted.mean,units) -export("%*%") export(as.units) export(as_cf) export(as_difftime) diff --git a/R/arith.R b/R/arith.R index 936d861f..34ff483e 100644 --- a/R/arith.R +++ b/R/arith.R @@ -131,34 +131,34 @@ Ops.units <- function(e1, e2) { .as.units(NextMethod(), u) } -#' matrix multiplication -#' @name matmult -#' @param x numeric matrix or vector -#' @param y numeric matrix or vector -#' @export -#' @details see \code{"\link[base]{\%*\%}"} for the base function, reimplemented -#' as default method -`%*%` = function(x, y) UseMethod("%*%") +##' matrix multiplication +##' @name matmult +##' @param x numeric matrix or vector +##' @param y numeric matrix or vector +##' @export +##' @details see \code{"\link[base]{\%*\%}"} for the base function, reimplemented +##' as default method +#`%*%` = function(x, y) UseMethod("%*%") -#' @name matmult -#' @export -`%*%.default` = function(x, y) { - if (inherits(y, "units")) - `%*%.units`(x, y) - else - base::`%*%`(x, y) -} +##' @name matmult +##' @export +#`%*%.default` = function(x, y) { +# if (inherits(y, "units")) +# `%*%.units`(x, y) +# else +# base::`%*%`(x, y) +#} -#' @name matmult -#' @export -#' @examples -#' a = set_units(1:5, m) -#' a %*% a -#' a %*% t(a) -#' a %*% set_units(1:5, 1) -#' set_units(1:5, 1) %*% a -`%*%.units` = function(x, y) { - ret = `%*%.default`(unclass(x), unclass(y)) - units(ret) = .multiply_symbolic_units(1, units(x), units(y)) - ret -} +##' @name matmult +##' @export +##' @examples +##' a = set_units(1:5, m) +##' a %*% a +##' a %*% t(a) +##' a %*% set_units(1:5, 1) +##' set_units(1:5, 1) %*% a +#`%*%.units` = function(x, y) { +# ret = `%*%.default`(unclass(x), unclass(y)) +# units(ret) = .multiply_symbolic_units(1, units(x), units(y)) +# ret +#} diff --git a/man/matmult.Rd b/man/matmult.Rd deleted file mode 100644 index f76fa400..00000000 --- a/man/matmult.Rd +++ /dev/null @@ -1,36 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/arith.R -\name{matmult} -\alias{matmult} -\alias{\%*\%} -\alias{matmult} -\alias{\%*\%.default} -\alias{matmult} -\alias{\%*\%.units} -\title{matrix multiplication} -\usage{ -x \%*\% y - -\method{\%*\%}{default}(x, y) - -\method{\%*\%}{units}(x, y) -} -\arguments{ -\item{x}{numeric matrix or vector} - -\item{y}{numeric matrix or vector} -} -\description{ -matrix multiplication -} -\details{ -see \code{"\link[base]{\%*\%}"} for the base function, reimplemented - as default method -} -\examples{ -a = set_units(1:5, m) -a \%*\% a -a \%*\% t(a) -a \%*\% set_units(1:5, 1) -set_units(1:5, 1) \%*\% a -}