Skip to content

Commit 89c115e

Browse files
Merge pull request #38 from jonathan-taylor/master
change to C library -- allowing for row major ordering, adjusted wrapper
2 parents 232760d + 8bd3c12 commit 89c115e

File tree

5 files changed

+11
-7
lines changed

5 files changed

+11
-7
lines changed

selectiveInference/NAMESPACE

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,3 @@ importFrom("stats", "coef", "df", "lm", "pf")
4545
importFrom("stats", "glm", "residuals", "vcov")
4646
importFrom("stats", "rbinom", "rexp")
4747
importFrom("Rcpp", "sourceCpp")
48-

selectiveInference/R/funs.randomized.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,13 @@ randomizedLASSO = function(X,
4545
soln = rep(0, p)
4646
Xsoln = rep(0, n)
4747
linear_func = (- t(X) %*% y - perturb_) / n
48+
4849
gradient = 1. * linear_func
4950
ever_active = rep(0, p)
5051
nactive = as.integer(0)
5152

5253
result = solve_QP_wide(X, # design matrix
53-
lam / n, # vector of Lagrange multipliers
54+
lam / n, # vector of Lagrange multipliers
5455
ridge_term / n, # ridge_term
5556
max_iter,
5657
soln,
@@ -66,7 +67,6 @@ randomizedLASSO = function(X,
6667
objective_stop, # objective_stop
6768
kkt_stop, # kkt_stop
6869
param_stop) # param_stop
69-
7070

7171
sign_soln = sign(result$soln)
7272

selectiveInference/src/Rcpp-debias.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ Rcpp::List solve_QP_wide(Rcpp::NumericMatrix X,
101101
int param_stop
102102
) {
103103

104+
int column_major = 1; // R has matrices in column major order
104105
int ncase = X.nrow(); // number of cases
105106
int nfeature = X.ncol(); // number of features
106107

@@ -139,6 +140,7 @@ Rcpp::List solve_QP_wide(Rcpp::NumericMatrix X,
139140
(int *) nactive.begin(),
140141
ncase,
141142
nfeature,
143+
column_major,
142144
(double *) bound.begin(),
143145
ridge_term,
144146
(double *) theta.begin(),
@@ -162,6 +164,7 @@ Rcpp::List solve_QP_wide(Rcpp::NumericMatrix X,
162164
(int *) need_update.begin(),
163165
nfeature,
164166
ncase,
167+
column_major,
165168
(double *) bound.begin(),
166169
ridge_term,
167170
kkt_tol);
@@ -176,7 +179,8 @@ Rcpp::List solve_QP_wide(Rcpp::NumericMatrix X,
176179
(double *) linear_func.begin(),
177180
(int *) need_update.begin(),
178181
nfeature,
179-
ncase);
182+
ncase,
183+
column_major);
180184

181185
return(Rcpp::List::create(Rcpp::Named("soln") = theta,
182186
Rcpp::Named("gradient") = gradient,

tests/test_QP.R

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
library(selectiveInference)
22
### Test
3-
43
n = 80; p = 50
54

5+
66
X = matrix(rnorm(n * p), n, p)
77
Y = rnorm(n)
88
lam = 2
@@ -14,4 +14,5 @@ soln2 = coef(G, s=lam/n, exact=TRUE, x=X, y=Y)[-1]
1414
print(soln1)
1515
print(soln2)
1616
plot(soln1, soln2)
17-
print(summary(lm(soln1 ~ soln2)))
17+
print(summary(lm(soln1 ~ soln2)))
18+

0 commit comments

Comments
 (0)