Skip to content

Commit

Permalink
site rebuild
Browse files Browse the repository at this point in the history
  • Loading branch information
thk686 committed Aug 11, 2021
1 parent 5c7b2a5 commit bc8cb4f
Show file tree
Hide file tree
Showing 13 changed files with 169 additions and 166 deletions.
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# kdtools 0.5.2

* Returning distances from nearest neighbor search
* More accomodations for broken compilers

# kdtools 0.5.1

* Native R matrix support
Expand Down
39 changes: 19 additions & 20 deletions R/kdtools.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,30 @@ colspec <- function(x, cols = NULL) {

#' Sort multidimensional data
#' @param x a matrix or arrayvec object
#' @param parallel use multiple threads if true
#' @param inplace sort as a side-effect if true
#' @param cols column indices or names
#' @param ... ignored
#' @details The algorithm used is a divide-and-conquer quicksort variant that
#' recursively partitions an range of tuples using the median of each successive
#' dimension. Ties are resolved by cycling over successive dimensions. The
#' result is an ordering of tuples matching their order if they were inserted
#' into a kd-tree.
#' recursively partitions an range of tuples using the median of each
#' successive dimension. Ties are resolved by cycling over successive
#' dimensions. The result is an ordering of tuples matching their order if
#' they were inserted into a kd-tree.
#'
#' \code{kd_order} returns permutation vector that will order the rows of the
#' original matrix, exactly as \code{\link{order}}. If \code{inplace} is true,
#' then \code{kd_order} will also sort the arrayvec object as a side effect.
#' This can be more efficient when many subsequent queries are required.
#'
#' \code{kd_sort} and \code{kd_order} have been extended to work directly on a
#' data frame. All vector column types are supported (even lists of objects as
#' long as equality and comparison operators are defined). Additional, the
#' user can specify a sequence of column indices that will be used for
#' sorting. These can be a subset of columns and given in any order.
#' \code{kd_sort} and \code{kd_order} have been extended to work directly on R
#' native data.frame and matrix types. All vector column types are supported
#' (even lists of objects as long as equality and comparison operators are
#' defined). Additional, the user can specify a sequence of column indices
#' that will be used for sorting. These can be a subset of columns and given
#' in any order.
#' @return \tabular{ll}{\code{kd_sort} \tab the table sorted in kd-tree order
#' \cr \code{kd_order} \tab a permutation vector \cr \code{kd_is_sorted} \tab
#' a boolean \cr}
#' @note The matrix version will be slower because of data structure
#' conversions.
#' @examples
#' if (has_cxx17()) {
#' z <- data.frame(real = runif(10), lgl = runif(10) > 0.5,
Expand All @@ -56,14 +58,12 @@ colspec <- function(x, cols = NULL) {
#' @export
kd_sort <- function(x, ...) UseMethod("kd_sort")

#' @param parallel use multiple threads if true
#' @rdname kdsort
#' @export
kd_sort.matrix <- function(x, cols = NULL, parallel = TRUE, ...) {
return(x[kd_order(x, cols = colspec(x, cols), parallel = parallel),, drop = FALSE])
}

#' @param inplace sort as a side-effect if true
#' @rdname kdsort
#' @export
kd_sort.arrayvec <- function(x, inplace = FALSE, parallel = TRUE, ...) {
Expand Down Expand Up @@ -102,7 +102,6 @@ kd_order.arrayvec <- function(x, inplace = FALSE, parallel = TRUE, ...) {
return(kd_order_(x, inplace = inplace, parallel = parallel))
}

#' @param cols integer vector of column indices
#' @rdname kdsort
#' @export
kd_order.data.frame <- function(x, cols = NULL, parallel = TRUE, ...) {
Expand Down Expand Up @@ -157,7 +156,10 @@ lex_sort.arrayvec <- function(x, inplace = FALSE, ...) {
#' Search sorted data
#' @param x an object sorted by \code{\link{kd_sort}}
#' @param v a vector specifying where to look
#' @param ... additional arguments
#' @param l lower left corner of search region
#' @param u upper right corner of search region
#' @param cols integer vector of column indices
#' @param ... ignored
#' @return \tabular{ll}{\code{kd_lower_bound} \tab a row of values (vector) \cr
#' \code{kd_upper_bound} \tab a row of values (vector) \cr
#' \code{kd_range_query} \tab a set of rows in the same format as the sorted input \cr
Expand Down Expand Up @@ -205,8 +207,6 @@ kd_upper_bound.arrayvec <- function(x, v) {
return(kd_upper_bound_(x, v))
}

#' @param l lower left corner of search region
#' @param u upper right corner of search region
#' @rdname search
#' @export
kd_range_query <- function(x, l, u, ...) UseMethod("kd_range_query")
Expand Down Expand Up @@ -246,7 +246,6 @@ kd_rq_indices.arrayvec <- function(x, l, u, ...) {
}

#' @rdname search
#' @param cols integer vector of column indices
#' @export
kd_rq_indices.data.frame <- function(x, l, u, cols = NULL, ...) {
return(kd_rq_df(x, colspec(x, cols), l, u))
Expand All @@ -273,6 +272,8 @@ kd_binary_search.arrayvec <- function(x, v) {
#' @param x an object sorted by \code{\link{kd_sort}}
#' @param v a vector specifying where to look
#' @param n the number of neighbors to return
#' @param cols integer indices of columns to use
#' @param w distance weights
#' @param ... additional arguments
#' @return \tabular{ll}{
#' \code{kd_nearest_neighbors} \tab one or more rows from the sorted input \cr
Expand Down Expand Up @@ -305,8 +306,6 @@ kd_nearest_neighbors.arrayvec <- function(x, v, n, ...) {
return(kd_nearest_neighbors_(x, v, n))
}

#' @param cols integer indices of columns to use
#' @param w distance weights
#' @rdname nneighb
#' @export
kd_nearest_neighbors.data.frame <- function(x, v, n, cols = NULL, w = NULL, ...) {
Expand Down
10 changes: 3 additions & 7 deletions cran-comments.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@
0 errors | 0 warnings | 1 note

* This is a new release.

## Release notes

* I have added a configure/configure.win so that the package now should pass checks when CXX17 is not defined.
* I have tested this on rhub and winbuilder -- hopefully I got it right this time!
* My sincere appologies if this is a duplicate submission -- I did not get a receipt and I could not find the package in CRAN incoming after my last attempt.

* New config checks for c++17 and tests for type deduction issues
* Tested on winbuilder and rhub
* Sorry this has taken so many tries -- figures crossed!
78 changes: 39 additions & 39 deletions docs/articles/kdtools.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit bc8cb4f

Please sign in to comment.