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
# Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393

#' fast Euclidean distance matrix
#'
#' @param x matrix with sample rows for which the distance matrix is computed (to use with vectors, use \code{as.matrix(x)})
#' @examples
#' #require(microbenchmark)
#' #x = rnorm(100)
#' #microbenchmark(fastdist(as.matrix(x)),as.matrix(dist(x)))
#' @export
fastdist <- function(x) {
    .Call('_multivariance_fastdist', PACKAGE = 'multivariance', x)
}

#' double center a symmetric matrix
#'
#' @param x symmetric matrix
#' @param normalize boolean. If \code{TRUE} the matrix will be normalized to mean 1.
#' @keywords internal
doubleCenterSymMat <- function(x, normalize) {
    .Call('_multivariance_doubleCenterSymMat', PACKAGE = 'multivariance', x, normalize)
}

#' fast centered Euclidean distance matrix
#'
#' @param x matrix with sample rows for which the distance matrix is computed (to use with vectors, use \code{as.matrix(x)})
#' @param normalize boolean. If \code{TRUE} the matrix will be normalized to mean 1.
#' @export
fastEuclideanCdm <- function(x, normalize) {
    .Call('_multivariance_fastEuclideanCdm', PACKAGE = 'multivariance', x, normalize)
}

#' for the fast detection of the full dependence structure
#'
#' Returns the row indicies of matrix A which match with B
#'
#' @param A matrix
#' @param B matrix whose rows are subset of A
#'
#' @examples
#' # A = t(utils::combn(10,3))
#' # B = A[sort(sample.int(nrow(A),10)),]
#' # match_rows(A,B)
#'
#' @keywords internal
match_rows <- function(A, B) {
    .Call('_multivariance_match_rows', PACKAGE = 'multivariance', A, B)
}

#' bias corrected double centering
#' # included for speed comparison
#'
#' @keywords internal
doubleCenterBiasCorrected <- function(x) {
    .Call('_multivariance_doubleCenterBiasCorrected', PACKAGE = 'multivariance', x)
}

#' bias corrected double centering with normalizing
#' # included for speed comparison
#'
#' @keywords internal
doubleCenterBiasCorrectedUpper <- function(x) {
    .Call('_multivariance_doubleCenterBiasCorrectedUpper', PACKAGE = 'multivariance', x)
}

#' bias corrected double centering with normalizing constants for upper and lower bound
#'
#' @keywords internal
doubleCenterBiasCorrectedUpperLower <- function(x, n) {
    .Call('_multivariance_doubleCenterBiasCorrectedUpperLower', PACKAGE = 'multivariance', x, n)
}