Skip to content

Commit

Permalink
resoved issue #47
Browse files Browse the repository at this point in the history
  • Loading branch information
markvanderloo committed Aug 12, 2016
1 parent 22a953a commit b904e31
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 9 deletions.
Empty file modified build.bash
100644 → 100755
Empty file.
Empty file modified compile.sh
100644 → 100755
Empty file.
Empty file modified document.bash
100644 → 100755
Empty file.
Empty file modified drat.sh
100644 → 100755
Empty file.
14 changes: 9 additions & 5 deletions pkg/R/stringdist.R
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@ stringdistmatrix <- function(a, b
, method=method
, useBytes=useBytes
, weight=weight
, q=q
, p=p
, useNames=useNames
, nthread=nthread)
)
Expand Down Expand Up @@ -341,11 +343,13 @@ do_dist <- function(a, b, method, weight, maxDist=Inf, q, p, useBytes=FALSE, nth

# more efficient function that returns a square distance matrix as a 'stats::dist' object.
lower_tri <- function(a
, method=c("osa","lv","dl","hamming","lcs","qgram","cosine","jaccard","jw","soundex")
, useBytes = FALSE
, weight=c(d=1,i=1,s=1,t=1), q=1, p=0
, useNames=FALSE
, nthread = getOption("sd_num_thread")
, method=c("osa","lv","dl","hamming","lcs","qgram","cosine","jaccard","jw","soundex")
, useBytes = FALSE
, weight=c(d=1,i=1,s=1,t=1)
, q=1
, p=0
, useNames=FALSE
, nthread = getOption("sd_num_thread")
){
methnr <- METHODS[method]
if (is.na(method)){
Expand Down
8 changes: 4 additions & 4 deletions pkg/src/Rstringdist.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ SEXP R_lower_tri(SEXP a, SEXP method
, n_threads = 1
, col_max = n-1;

R_xlen_t p = 0
R_xlen_t pp = 0
, k_start = 0
, k_end = N;

Expand All @@ -317,9 +317,9 @@ SEXP R_lower_tri(SEXP a, SEXP method
n_threads = omp_get_num_threads();
#endif
// some administration to parallelize the loop.
p = N / n_threads;
k_start = thread_id * p;
k_end = (thread_id < n_threads - 1 ) ? k_start + p : N;
pp = N / n_threads;
k_start = thread_id * pp;
k_end = (thread_id < n_threads - 1 ) ? k_start + pp : N;
j = get_j(k_start,n);
i = k_start + j * (j - 2*n + 3)/2;
for ( R_xlen_t k=k_start; k < k_end; k++ ){
Expand Down
1 change: 1 addition & 0 deletions pkg/src/qgram.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ typedef enum { uInt, Double, Qtree } type;
static void *alloc(type t){
Shelf *shelf = &wall[get_shelf_num()];


if (
shelf->nboxes == 0L &&
!add_box(MIN_BOX_SIZE)
Expand Down
6 changes: 6 additions & 0 deletions pkg/tests/testthat/testStringdist.R
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,12 @@ test_that("stringdistmatrix with single argument",{
, c("k1","k2")
)

# bug reported by Max Fritsche; issue #47
x <- c("aap","apen")
expect_equivalent(
as.matrix(stringdistmatrix(x,method="jw",p=0.1))
, stringdistmatrix(x,x,method="jw",p=0.1)
)

})

Expand Down
Empty file modified ubsan.sh
100644 → 100755
Empty file.

0 comments on commit b904e31

Please sign in to comment.