Skip to content

Commit

Permalink
initial take at #3639 -- proper handling of CPLXSXP in dogroups
Browse files Browse the repository at this point in the history
remove debugging helpers

remove debugging helpers

remove debugging helpers
  • Loading branch information
Michael Chirico committed Jul 10, 2019
1 parent 4e3868b commit bf4fb10
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
1 change: 0 additions & 1 deletion R/data.table.R
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,6 @@ replace_order = function(isub, verbose, env) {
} # else maybe a call to transform or something which returns a list.
av = all.vars(jsub,TRUE) # TRUE fixes bug #1294 which didn't see b in j=fns[[b]](c)
use.I = ".I" %chin% av
# browser()
if (any(c(".SD","eval","get","mget") %chin% av)) {
if (missing(.SDcols)) {
# here we need to use 'dupdiff' instead of 'setdiff'. Ex: setdiff(c("x", "x"), NULL) will give 'x'.
Expand Down
19 changes: 16 additions & 3 deletions src/dogroups.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <Rdefines.h>
#include <fcntl.h>
#include <time.h>
#include <complex.h>

SEXP dogroups(SEXP dt, SEXP dtcols, SEXP groups, SEXP grpcols, SEXP jiscols, SEXP xjiscols, SEXP grporder, SEXP order, SEXP starts, SEXP lens, SEXP jexp, SEXP env, SEXP lhs, SEXP newnames, SEXP on, SEXP verbose)
{
Expand Down Expand Up @@ -214,13 +215,20 @@ SEXP dogroups(SEXP dt, SEXP dtcols, SEXP groups, SEXP grpcols, SEXP jiscols, SEX
rownum = iI[k]-1;
td[k] = sd[rownum]; // on 32bit copies pointers too
}
} else { // size 8
} else if (size==8) {
double *td = REAL(target);
const double *sd = REAL(source);
for (int k=0; k<grpn; ++k) {
rownum = iI[k]-1;
td[k] = sd[rownum]; // on 64bit copies pointers too
}
} else { // size 16
double complex *td = (double complex *)COMPLEX(target);
const double complex *sd = (double complex *)COMPLEX(source);
for (int k=0; k<grpn; ++k) {
rownum = iI[k]-1;
td[k] = ds[rownum];
}
}
}
if (LOGICAL(verbose)[0]) { tblock[1] += clock()-tstart; nblock[1]++; }
Expand Down Expand Up @@ -382,14 +390,19 @@ SEXP dogroups(SEXP dt, SEXP dtcols, SEXP groups, SEXP grpcols, SEXP jiscols, SEX
for (int j=0; j<ngrpcols; ++j) {
target = VECTOR_ELT(ans,j);
source = VECTOR_ELT(groups, INTEGER(grpcols)[j]-1); // target and source the same type by construction above
if (SIZEOF(target)==4) {
int tsize = SIZEOF(target);
if (tsize==4) {
int *td = INTEGER(target);
int *sd = INTEGER(source);
for (int r=0; r<maxn; ++r) td[ansloc+r] = sd[igrp];
} else {
} else if (tsize==8) {
double *td = REAL(target);
double *sd = REAL(source);
for (int r=0; r<maxn; ++r) td[ansloc+r] = sd[igrp];
} else {
double complex *td = COMPLEX(target);
double complex *sd = COMPLEX(source);
for (int r=0; r<maxn; ++r) td[ansloc+r] = sd[igrp];
}
// Shouldn't need SET_* to age objects here since groups, TO DO revisit.
}
Expand Down

0 comments on commit bf4fb10

Please sign in to comment.