~hrbrmstr/tdigest

6b6b44375e757ac379815d2641b1e937d70d0f66 — hrbrmstr 4 years ago 1148b04
bb8
3 files changed, 27 insertions(+), 3 deletions(-)

M .Rbuildignore
A cran-comments.md
M src/tdigest.c
M .Rbuildignore => .Rbuildignore +1 -0
@@ 16,3 16,4 @@
^notes$
^\.gitlab-ci\.yml$
^appveyor\.yml$
^cran-comments\.md$

A cran-comments.md => cran-comments.md +19 -0
@@ 0,0 1,19 @@
## Test environments
* local OS X install, R 3.6.1
* ubuntu 14.04 (on travis-ci), R 3.6.1
* win-builder (devel and release)
* r-hub (CRAN default build)
* appveyor, R 3.6.1

## R CMD check results

0 errors | 0 warnings | 1 note

* This is a new release.

Hey CRAN team members! There is no rush 
to get this processed whatsoever so if 
there are package authors who have 
asked for any acceleration of their 
package evaluation please do not hesitate
to put them ahead of this in the queue.
\ No newline at end of file

M src/tdigest.c => src/tdigest.c +7 -3
@@ 5,13 5,17 @@

#include "tdigest.h"

#define M_PI 3.14159265358979323846
#define MM_PI 3.14159265358979323846

typedef struct node {
     double mean;
     double count;
} node_t;

void bbzero(void *to, size_t count) {
  memset(to, 0, count);
}

struct td_histogram {
     // compression is a setting used to configure the size of centroids when merged.
     double compression;


@@ 69,7 73,7 @@ static td_histogram_t *td_init(double compression, size_t buf_size, char *buf) {
     if (!h) {
          return NULL;
     }
     bzero((void *)(h), buf_size);
     bbzero((void *)(h), buf_size);
     *h = (td_histogram_t) {
          .compression = compression,
          .cap = (buf_size - sizeof(td_histogram_t)) / sizeof(node_t),


@@ 219,7 223,7 @@ static void merge(td_histogram_t *h) {
     int N = h->merged_nodes + h->unmerged_nodes;
     qsort((void *)(h->nodes), N, sizeof(node_t), &compare_nodes);
     double total_count = h->merged_count + h->unmerged_count;
     double denom = 2 * M_PI * total_count * log(total_count);
     double denom = 2 * MM_PI * total_count * log(total_count);
     double normalizer = h->compression / denom;
     int cur = 0;
     double count_so_far = 0;