Skip to content

Commit 6a98f7e

Browse files
committed
first commit
0 parents  commit 6a98f7e

File tree

12 files changed

+2033
-0
lines changed

12 files changed

+2033
-0
lines changed

README.md

Whitespace-only changes.

SGLP/README.MD

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#Sparse Group Lasso Projection (SGLP) problem
2+
sglp.c
3+
sglp_admm.m
4+
sglp_dykstra.m
5+
glLeast.c
6+
7+
#Constrained Sparse Group Lasso Problem (CSGLP)
8+
sglLeastC.m
9+
sglLeastC_admm.m
10+
11+
#DC programming for truncated norm
12+
trunc_sglp.c
13+
trunc_sglLeastC.m
14+
trunc_DC_sglLeastC.m
15+
16+
#Usage
17+
The SLEP package is required. You may download the latest version at http://www.public.asu.edu/~jye02/Software/SLEP/.
18+
Compile the c files using ordinary mex tool:
19+
mex sglp.c/glLeast.c/trunc_sglp.c
20+
21+
22+
23+
24+
25+
26+

SGLP/glLeastC.c

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*function [ x, lambda ] = glLeastC( v, radius, ind, w, u )
2+
3+
Solve the following group projection:
4+
5+
\min_{x} \| x - v \|_2
6+
subject to \sum \|x_{G_i}\|_2 <= radius,
7+
8+
where the group information is contained in the "ind" array
9+
Require SLEP package, the "eplb" function.
10+
*/
11+
12+
#include <math.h>
13+
#include "mex.h"
14+
#include "SLEP_4.0/SLEP/CFiles/q1/epph.h"
15+
16+
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
17+
{
18+
double *v, *ind, *w, *u, *x, *lambda;
19+
double radius, lambda0, sum;
20+
21+
int n, grpNum;
22+
int i, j, k, steps, be, en;
23+
24+
if(nlhs != 2)
25+
mexErrMsgTxt("Error: Number of output parameter does not match.");
26+
27+
if(nrhs !=5)
28+
mexErrMsgTxt("Error: Number of input parameter does not match.");
29+
30+
n = mxGetNumberOfElements(prhs[0]);
31+
grpNum = mxGetNumberOfElements(prhs[2]) - 1;
32+
lambda0 = .0;
33+
34+
v = mxGetPr(prhs[0]);
35+
radius = mxGetScalar(prhs[1]);
36+
ind = mxGetPr(prhs[2]);
37+
w = mxGetPr(prhs[3]);
38+
u = mxGetPr(prhs[4]);
39+
40+
41+
plhs[0] = mxCreateDoubleMatrix(n, 1, mxREAL);
42+
plhs[1] = mxCreateDoubleMatrix(1, 1, mxREAL);
43+
x = mxGetPr(plhs[0]);
44+
lambda = mxGetPr(plhs[1]);
45+
46+
for(i = 0; i < grpNum; i++)
47+
{
48+
sum = .0;
49+
be = (int)ind[i], en = (int)ind[i+1];
50+
for(j = be; j < en; j++)
51+
sum += v[j] * v[j];
52+
w[i] = sqrt(sum);
53+
}
54+
55+
eplb(u, lambda, &steps, w, grpNum, radius, lambda0);
56+
57+
for(i = 0, j = 0; j < grpNum; j++)
58+
{
59+
be = (int)ind[j], en = (int)ind[j+1];
60+
61+
if(fabs(w[j]) > 1e-15)
62+
for(i = be; i < en; i++)
63+
x[i] = u[j] * v[i] / w[j];
64+
else
65+
for(i = be; i < en; i++)
66+
x[i] = 0;
67+
}
68+
}
69+

0 commit comments

Comments
 (0)