Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Makevars
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
PKG_LIBS = $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) `$(R_HOME)/bin/Rscript -e "Rcpp:::LdFlags()"`
PKG_LIBS = $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)
PKG_CPPFLAGS = -DUSE_FC_LEN_T
2 changes: 1 addition & 1 deletion src/r_smahal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ SEXP r_smahal(SEXP index, SEXP data, SEXP z) {
Rcpp::NumericMatrix dataMat(data);
DMAT * ans = smahal(dataMat.nrow(), dataMat.ncol(), REAL(data), LOGICAL(z));
if(ans == NULL || ans->nr < 1 || ans->nc <1)
Rf_error("smahal_nosexp returned an invalid answer");
Rcpp::stop("smahal_nosexp returned an invalid answer");

SEXP out;
Rf_protect(out = Rf_allocMatrix(REALSXP, ans->nr, ans->nc));
Expand Down
13 changes: 7 additions & 6 deletions src/smahal.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "smahal.h"
#include <Rcpp.h>

void rank(int n, const double * data, double * ranks) {
double
Expand Down Expand Up @@ -36,7 +37,7 @@ bool rerank_dups(int n, const double * data, double * ranks) {
if(data[j] == data[i]) {
dup_idx[ndups] = j;
ndups++;
any_ties = true;
any_ties = true;
mean_rank += ranks[j];
visited[j] = 1;
}
Expand Down Expand Up @@ -151,19 +152,19 @@ void ginv_square(double * square_mat, int n) {
}

if(info < 0)
Rf_error("dgesdd: problem with one of the arguments");
Rcpp::stop("dgesdd: problem with one of the arguments");
else if(info > 0)
Rf_error("dgesdd: dbdsdc did not converge, updating process failed");
Rcpp::stop("dgesdd: dbdsdc did not converge, updating process failed");

double
smax = dmax(n, s),
cutoff = 1e-10 * smax;

for(int i = 0; i < n; i++) {
if(s[i] > cutoff)
s[i] = 1.0 / s[i];
s[i] = 1.0 / s[i];
else
s[i] = 0.0;
s[i] = 0.0;
}

transpose_sq(n, vt);
Expand Down Expand Up @@ -274,7 +275,7 @@ DMAT * smahal(int nr, int nc, double * data, int * z) {

DMAT * out_distances = R_Calloc(1, DMAT);
if(out_distances == NULL)
Rf_error("smahal:out_distances:NULL R_Calloc\n");
Rcpp::stop("smahal:out_distances:NULL R_Calloc\n");

out_distances->data = R_Calloc(ntreat * ncontrol, double);
out_distances->nr = ntreat;
Expand Down