Skip to content

Commit

Permalink
Use tabulate, remove fast_table
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean-Romain committed Sep 6, 2019
1 parent be87967 commit 45a01f4
Show file tree
Hide file tree
Showing 7 changed files with 5 additions and 35 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
### rlas v1.3.4

- Fix: One Definition Rule (ODR) violation in LASzip (LTO issue)
- Note: use the function `tabulate()` instead of home made C++ code to count the return numbers.

### rlas v1.3.3

Expand Down
4 changes: 0 additions & 4 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
# Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393

fast_table <- function(x, size = 5L) {
.Call(`_rlas_fast_table`, x, size)
}

fast_countequal <- function(x, t) {
.Call(`_rlas_fast_countequal`, x, t)
}
Expand Down
2 changes: 1 addition & 1 deletion R/deprecated.r
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ check_data_vs_header = function(header, data, ...)
{
n <- if (header[["Version Minor"]] < 4L) 5L else 15L
header_number_of <- header[["Number of points by return"]]
actual_number_of <- fast_table(data$ReturnNumber, n)
actual_number_of <- tabulate(data$ReturnNumber, n)

for (i in 1:n)
{
Expand Down
4 changes: 2 additions & 2 deletions R/header_tools.r
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ header_create = function(data)
header[["Z scale factor"]] = 0.01

if ("ReturnNumber" %in% fields)
header[["Number of points by return"]] <- fast_table(data$ReturnNumber, 5L)
header[["Number of points by return"]] <- tabulate(data$ReturnNumber, 5L)
else
header[["Number of points by return"]] <- rep(0L,5)

Expand Down Expand Up @@ -161,7 +161,7 @@ header_update = function(header, data)
if ("ReturnNumber" %in% fields)
{
n <- if (header[["Version Minor"]] < 4) 5L else 15L
header[["Number of points by return"]] <- fast_table(data$ReturnNumber, n)
header[["Number of points by return"]] <- tabulate(data$ReturnNumber, n)
}

header[["Number of point records"]] = npts
Expand Down
2 changes: 1 addition & 1 deletion R/las_specifications.r
Original file line number Diff line number Diff line change
Expand Up @@ -986,7 +986,7 @@ is_number_of_points_by_return_in_accordance_with_header = function(header, data,

n <- if (header[["Version Minor"]] < 4L) 5L else 15L
header_number_of <- header[["Number of points by return"]]
actual_number_of <- fast_table(data$ReturnNumber, n)
actual_number_of <- tabulate(data$ReturnNumber, n)

for (i in 1:n)
{
Expand Down
13 changes: 0 additions & 13 deletions src/RcppExports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,6 @@

using namespace Rcpp;

// fast_table
IntegerVector fast_table(IntegerVector x, int size);
RcppExport SEXP _rlas_fast_table(SEXP xSEXP, SEXP sizeSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< IntegerVector >::type x(xSEXP);
Rcpp::traits::input_parameter< int >::type size(sizeSEXP);
rcpp_result_gen = Rcpp::wrap(fast_table(x, size));
return rcpp_result_gen;
END_RCPP
}
// fast_countequal
int fast_countequal(IntegerVector x, int t);
RcppExport SEXP _rlas_fast_countequal(SEXP xSEXP, SEXP tSEXP) {
Expand Down Expand Up @@ -113,7 +101,6 @@ END_RCPP
}

static const R_CallMethodDef CallEntries[] = {
{"_rlas_fast_table", (DL_FUNC) &_rlas_fast_table, 2},
{"_rlas_fast_countequal", (DL_FUNC) &_rlas_fast_countequal, 2},
{"_rlas_fast_countbelow", (DL_FUNC) &_rlas_fast_countbelow, 2},
{"_rlas_fast_countover", (DL_FUNC) &_rlas_fast_countover, 2},
Expand Down
14 changes: 0 additions & 14 deletions src/fast.cpp
Original file line number Diff line number Diff line change
@@ -1,20 +1,6 @@
#include <Rcpp.h>
using namespace Rcpp;

// [[Rcpp::export]]
IntegerVector fast_table(IntegerVector x, int size = 5)
{
IntegerVector tbl(size);

for (IntegerVector::iterator it = x.begin(), end = x.end() ; it != end ; ++it)
{
if (*it <= size && *it > 0)
tbl(*it-1)++;
}

return tbl;
}

// [[Rcpp::export]]
int fast_countequal(IntegerVector x, int t)
{
Expand Down

0 comments on commit 45a01f4

Please sign in to comment.