Skip to content

Commit

Permalink
Merge branch 'main' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
ManosPapadakis95 committed Nov 14, 2023
2 parents f20c937 + 99a5c98 commit d976a3e
Show file tree
Hide file tree
Showing 18 changed files with 1,413 additions and 120 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
],
"pch": "RcppArmadillo",
"is_cpp": true,
"hash": "169833942816977215341697721592",
"hash": "169834350316977215341697721592",
"compiler": "6762244524107556826",
"rversion": "4.3.1",
"dbversion": 4
Expand Down
14 changes: 7 additions & 7 deletions .Rproj.user/CB39D88C/pcs/windowlayoutstate.pper
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"left": {
"splitterpos": 559,
"topwindowstate": "NORMAL",
"panelheight": 959,
"windowheight": 997
"splitterpos": 458,
"topwindowstate": "MAXIMIZE",
"panelheight": 789,
"windowheight": 827
},
"right": {
"splitterpos": 564,
"splitterpos": 472,
"topwindowstate": "NORMAL",
"panelheight": 959,
"windowheight": 997
"panelheight": 744,
"windowheight": 782
}
}
4 changes: 2 additions & 2 deletions .Rproj.user/CB39D88C/persistent-state
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
build-last-errors="[]"
build-last-errors-base-dir="~/GitHub/Rnanoflann/"
build-last-outputs="[{\"type\":0,\"output\":\"==> Rcpp::compileAttributes()\\n\\n\"},{\"type\":1,\"output\":\"* Updated R/RcppExports.R\\r\\n\"},{\"type\":1,\"output\":\"\\n\"},{\"type\":0,\"output\":\"==> Rcmd.exe INSTALL --preclean --no-multiarch --with-keep.source Rnanoflann\\n\\n\"},{\"type\":1,\"output\":\"* installing to library 'C:/R/R-4.3.1/library'\\r\\n\"},{\"type\":1,\"output\":\"* installing *source* package 'Rnanoflann' ...\\r\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"** using staged installation\\r\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"** libs\\r\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"using C++ compiler: 'G__~1.EXE (GCC) 12.2.0'\\r\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"g++ -std=gnu++17 -I\\\"C:/R/R-4.3.1/include\\\" -DNDEBUG -I../inst/include -I'C:/R/R-4.3.1/library/Rcpp/include' -I'C:/R/R-4.3.1/library/RcppArmadillo/include' -I\\\"c:/rtools43/x86_64-w64-mingw32.static.posix/include\\\" -fopenmp -O3 -Wall -mfpmath=sse -msse2 -mstackrealign -c RcppExports.cpp -o RcppExports.o\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"g++ -std=gnu++17 -I\\\"C:/R/R-4.3.1/include\\\" -DNDEBUG -I../inst/include -I'C:/R/R-4.3.1/library/Rcpp/include' -I'C:/R/R-4.3.1/library/RcppArmadillo/include' -I\\\"c:/rtools43/x86_64-w64-mingw32.static.posix/include\\\" -fopenmp -O3 -Wall -mfpmath=sse -msse2 -mstackrealign -c knn.cpp -o knn.o\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"g++ -std=gnu++17 -shared -s -static-libgcc -o Rnanoflann.dll tmp.def RcppExports.o knn.o -fopenmp -LC:/R/R-4.3.1/bin/x64 -lRlapack -LC:/R/R-4.3.1/bin/x64 -lRblas -lgfortran -lm -lquadmath -Lc:/rtools43/x86_64-w64-mingw32.static.posix/lib/x64 -Lc:/rtools43/x86_64-w64-mingw32.static.posix/lib -LC:/R/R-4.3.1/bin/x64 -lR\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"installing to C:/R/R-4.3.1/library/00LOCK-Rnanoflann/00new/Rnanoflann/libs/x64\\r\\n\"},{\"type\":1,\"output\":\"** R\\r\\n\"},{\"type\":1,\"output\":\"** inst\\r\\n\"},{\"type\":1,\"output\":\"** byte-compile and prepare package for lazy loading\\r\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"** help\\r\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"*** installing help indices\\r\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"** building package indices\\r\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"** testing if installed package can be loaded from temporary location\\r\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"** testing if installed package can be loaded from final location\\r\\n\"},{\"type\":1,\"output\":\"\"},{\"type\":1,\"output\":\"** testing if installed package keeps a record of temporary installation path\\r\\n\"},{\"type\":1,\"output\":\"* DONE (Rnanoflann)\\r\\n\"},{\"type\":1,\"output\":\"\"}]"
build-last-errors-base-dir=""
build-last-outputs="[]"
compile_pdf_state="{\"tab_visible\":false,\"running\":false,\"target_file\":\"\",\"output\":\"\",\"errors\":[]}"
files.monitored-path=""
find-in-files-state="{\"handle\":\"\",\"input\":\"\",\"path\":\"\",\"regex\":false,\"ignoreCase\":false,\"results\":{\"file\":[],\"line\":[],\"lineValue\":[],\"matchOn\":[],\"matchOff\":[],\"replaceMatchOn\":[],\"replaceMatchOff\":[]},\"running\":false,\"replace\":false,\"preview\":false,\"gitFlag\":false,\"replacePattern\":\"\"}"
Expand Down
2 changes: 1 addition & 1 deletion .Rproj.user/CB39D88C/sources/per/t/08AB1D3B
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"source_window_id": "",
"Source": "Source",
"cursorPosition": "19,0",
"scrollLine": "12"
"scrollLine": "0"
},
"folds": "",
"lastKnownWriteTime": 1698240233,
Expand Down
2 changes: 1 addition & 1 deletion .Rproj.user/CB39D88C/sources/prop/B535BAD2
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"source_window_id": "",
"Source": "Source",
"cursorPosition": "19,0",
"scrollLine": "12"
"scrollLine": "0"
}
2 changes: 1 addition & 1 deletion .Rproj.user/CB39D88C/sources/prop/INDEX
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ C%3A%2FUsers%2Fepapadakis%2FDocuments%2FGitHub%2FRnanoflann%2Fsrc%2FKDTreeArmadi
C%3A%2FUsers%2Fepapadakis%2FDocuments%2FGitHub%2FRnanoflann%2Fsrc%2Fknn.cpp="5996C9E3"
~%2FGitHub%2FRfast%2FDESCRIPTION="372DE254"
~%2FGitHub%2FRfast%2FNEWS.md="6AEF0695"
~%2FGitHub%2FRnanoflann%2FDESCRIPTION="FFA56AA2"
~%2FGitHub%2FRnanoflann%2FDESCRIPTION="FFA56x2"
~%2FGitHub%2FRnanoflann%2FNAMESPACE="B073F41F"
~%2FGitHub%2FRnanoflann%2FNEWS.md="84751C78"
~%2FGitHub%2FRnanoflann%2FR%2Fknn.R="F422750D"
Expand Down
64 changes: 48 additions & 16 deletions .github/workflows/r.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
#
# See https://github.com/r-lib/actions/tree/master/examples#readme for
# additional example workflows available for the R community.

name: R


on:
push:
branches: [ "main" ]
Expand All @@ -18,23 +11,62 @@ permissions:
contents: read

jobs:
build:
windows:
name: windows
runs-on: windows-latest
strategy:
matrix:
r-version: ['4.3.1']

steps:
- uses: actions/checkout@v2
- name: Set up R ${{ matrix.r-version }}
uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.r-version }}
- name: Set CRAN mirror
run: echo 'options(repos = c(CRAN = "https://cloud.r-project.org/"))' >> $GITHUB_WORKSPACE/.Rprofile
- name: Install dependencies
run: |
install.packages("Rfast")
shell: Rscript {0}

macos:
name: macos
runs-on: macos-latest
strategy:
matrix:
r-version: ['3.5.0', '4.3.1']
r-version: ['4.3.2']

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v2
- name: Set up R ${{ matrix.r-version }}
uses: r-lib/actions/setup-r@f57f1301a053485946083d7a45022b278929a78a
uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.r-version }}
- name: Set CRAN mirror
run: echo 'options(repos = c(CRAN = "https://cloud.r-project.org/"))' >> $GITHUB_WORKSPACE/.Rprofile
- name: Install dependencies
run: |
install.packages(c("remotes", "rcmdcheck"))
remotes::install_deps(dependencies = TRUE)
install.packages("Rfast")
shell: Rscript {0}
- name: Check
run: rcmdcheck::rcmdcheck(args = "--no-manual", error_on = "error")

linux:
name: linux
runs-on: fedora-latest
strategy:
matrix:
r-version: ['4.3.1']

steps:
- uses: actions/checkout@v2
- name: Set up R ${{ matrix.r-version }}
uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.r-version }}
- name: Set CRAN mirror
run: echo 'options(repos = c(CRAN = "https://cloud.r-project.org/"))' >> $GITHUB_WORKSPACE/.Rprofile
- name: Install dependencies
run: |
install.packages("Rfast")
shell: Rscript {0}
87 changes: 87 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
{
"files.associations": {
"random": "cpp",
"array": "cpp",
"chrono": "cpp",
"deque": "cpp",
"format": "cpp",
"forward_list": "cpp",
"initializer_list": "cpp",
"list": "cpp",
"vector": "cpp",
"xhash": "cpp",
"xstring": "cpp",
"xtree": "cpp",
"xutility": "cpp",
"algorithm": "cpp",
"utility": "cpp",
"atomic": "cpp",
"bit": "cpp",
"cctype": "cpp",
"charconv": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"compare": "cpp",
"concepts": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"exception": "cpp",
"fstream": "cpp",
"iomanip": "cpp",
"ios": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"iterator": "cpp",
"limits": "cpp",
"locale": "cpp",
"map": "cpp",
"memory": "cpp",
"mutex": "cpp",
"new": "cpp",
"optional": "cpp",
"ostream": "cpp",
"ratio": "cpp",
"sstream": "cpp",
"stack": "cpp",
"stdexcept": "cpp",
"stop_token": "cpp",
"streambuf": "cpp",
"string": "cpp",
"system_error": "cpp",
"thread": "cpp",
"tuple": "cpp",
"type_traits": "cpp",
"typeinfo": "cpp",
"unordered_map": "cpp",
"xfacet": "cpp",
"xiosbase": "cpp",
"xlocale": "cpp",
"xlocbuf": "cpp",
"xlocinfo": "cpp",
"xlocmes": "cpp",
"xlocmon": "cpp",
"xlocnum": "cpp",
"xloctime": "cpp",
"xmemory": "cpp",
"xstddef": "cpp",
"xtr1common": "cpp",
"functional": "cpp",
"queue": "cpp",
"*.rmd": "markdown",
"unordered_set": "cpp",
"execution": "cpp",
"numeric": "cpp",
"*.f7": "html",
"future": "cpp",
"condition_variable": "cpp",
"coroutine": "cpp",
"resumable": "cpp"
},
"r.lsp.promptToInstall": false
}
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ Package: Rnanoflann
Type: Package
Title: Extremely Fast Nearest Neighbor Search
Version: 0.0.1
Date: 2023-10-26
Date: 2023-10-30
Authors@R: c(
person("Manos Papadakis", email = "[email protected]", role = c("aut", "cre", "cph")),
person("Jose Luis Blanco", email = "[email protected]" , role = c("aut","cph")),
person("Michail Tsagris", role = c("ctb"))
)
Maintainer: Manos Papadakis <[email protected]>
Copyright: nanoflann library is copyright Jose Luis Blanco. See file COPYRIGHT for details.
Description: Finds the k nearest neighbours for every point in a given dataset using Jose Luis' 'nanoflann' library. There is support for exact searches, fixed radius searches with 'kd' trees and two distances, the 'Euclidean' and 'Manhattan'. For more information see <https://github.com/jlblancoc/nanoflann>. Also, the nanoflann library is exported and ready to be used via the linking to mechanism.
Copyright: 'nanoflann' library is copyright Jose Luis Blanco. See file COPYRIGHT for details.
Description: Finds the k nearest neighbours for every point in a given dataset using Jose Luis' 'nanoflann' library. There is support for exact searches, fixed radius searches with 'kd' trees and two distances, the 'Euclidean' and 'Manhattan'. For more information see <https://github.com/jlblancoc/nanoflann>. Also, the 'nanoflann' library is exported and ready to be used via the linking to mechanism.
License: GPL (>= 3)
Imports: Rcpp (>= 1.0.11)
LinkingTo: Rcpp, RcppArmadillo
Expand Down
8 changes: 6 additions & 2 deletions R/nn.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
#[export]
nn <- function(data, points = data, k = nrow(data), method = "euclidean", search = "standard", eps = 0.0, square = FALSE,
sorted = FALSE, radius = 0.0, trans = TRUE, leafs = 10, parallel = FALSE, cores = 0){
sorted = FALSE, radius = 0.0, trans = TRUE, leafs = 10, p = 0.0, parallel = FALSE, cores = 0){
if(method == "hellinger"){
data <- sqrt(data)
points <- sqrt(points)
}
res <- .Call(`_Rnanoflann_nn`, t(data), t(points), k, method, search, eps, square,
sorted, radius, leafs, parallel, cores)
sorted, radius, leafs, p, parallel, cores)
if(trans){
res$indices <- t(res$indices)
res$distances <- t(res$distances)
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Rnanoflann ![Rnanoflann](https://raw.githubusercontent.com/jlblancoc/nanoflann/master/doc/logo.png)

[![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/Rnanoflann)](https://cran.r-project.org/package=Rnanoflann) [![metacran downloads](https://cranlogs.r-pkg.org/badges/grand-total/Rnanoflann)](https://cran.r-project.org/package=Rnanoflann) [![metacran downloads](https://cranlogs.r-pkg.org/badges/Rnanoflann)](https://cran.r-project.org/package=Rnanoflann) [![CRAN_latest_release_date](https://www.r-pkg.org/badges/last-release/Rnanoflann)](https://cran.r-project.org/package=Rnanoflann)
[![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/Rnanoflann)](https://cran.r-project.org/package=Rnanoflann) [![metacran downloads](https://cranlogs.r-pkg.org/badges/grand-total/Rnanoflann)](https://cran.r-project.org/package=Rnanoflann) [![metacran downloads](https://cranlogs.r-pkg.org/badges/Rnanoflann)](https://cran.r-project.org/package=Rnanoflann) [![CRAN_latest_release_date](https://www.r-pkg.org/badges/last-release/Rnanoflann)](https://cran.r-project.org/package=Rnanoflann) [![R](https://github.com/ManosPapadakis95/Rnanoflann/actions/workflows/r.yml/badge.svg)](https://github.com/ManosPapadakis95/Rnanoflann/actions/workflows/r.yml)



## 1. About
Expand Down
21 changes: 21 additions & 0 deletions inst/include/internal/Coeff.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@


#ifndef COEFF_H
#define COEFF_H

#include <RcppArmadillo.h>
#include <string>

using Rcpp::NumericMatrix;
using std::string;
using namespace arma;
using namespace Rcpp;

namespace Coeff
{
inline double bhattacharyya(colvec x, colvec y){
return sum(sqrt(x % y));
}
}

#endif
17 changes: 17 additions & 0 deletions inst/include/internal/Dist.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#pragma once
//[[Rcpp::depends(RcppArmadillo)]]
#include <RcppArmadillo.h>
using namespace arma;

namespace Dist
{
inline double manhattan(colvec x, colvec y)
{
return sum(abs(x - y));
}

inline double euclidean(colvec x, colvec y)
{
return sum(square(x - y));
}
}
Loading

0 comments on commit d976a3e

Please sign in to comment.