tests/testthat/test-rcpp_cubic_kernel.R

context("test-rcpp_cubic_kernel")

test_that("Testing Rcpp cubicKernel function", {
  ## Setting up
  source("setup.R")
  
  ##----------------------------------
  ## Kernel
  ##----------------------------------
  kernel <- "cubicKernel"

  
  ## Check
  res1 <- meanShiftOperator(x, points, h, kernel)
  res2 <- RcppMeanShiftOperator(x, points, h, kernel)
  expect_equal(sum(res1), sum(res2))
  

  ## Check
  res3 <- RcppMeanShiftAlgorithm(x, points, h, kernel, tol.stop)
  res4 <- meanShiftAlgorithm(x, points, h, kernel, tol.stop)

  expect_equal(sum(res3), sum(res4))
  
  ## Running msClustering
  rcpp.clustering <- msClustering( iris.data, h, kernel=kernel, multi.core=TRUE, legacy.mode=FALSE )
  non.rcpp.clustering <- msClustering( iris.data, h, kernel=kernel, multi.core=TRUE, legacy.mode=TRUE )
  
  expect_equal(sum(rcpp.clustering$components), sum(non.rcpp.clustering$components))
})
GenKawamura/HSMeanShift documentation built on Dec. 17, 2021, 9:28 p.m.