|
a |
|
b/MLFre/DPC/SLEP/findLambdaMax.c |
|
|
1 |
#include "mex.h" |
|
|
2 |
#include <stdio.h> |
|
|
3 |
#include <math.h> |
|
|
4 |
#include <string.h> |
|
|
5 |
#include "altra.h" |
|
|
6 |
|
|
|
7 |
|
|
|
8 |
/* |
|
|
9 |
* ------------------------------------------------------------------- |
|
|
10 |
* Function and parameter |
|
|
11 |
* ------------------------------------------------------------------- |
|
|
12 |
* |
|
|
13 |
* findLambdaMax compute |
|
|
14 |
* |
|
|
15 |
* the lambda_{max} that achieves a zero solution for |
|
|
16 |
* |
|
|
17 |
* min 1/2 \|x-v\|^2 + \lambda_{\max} * \sum w_i \|x_{G_i}\|, |
|
|
18 |
* |
|
|
19 |
* where x is of dimension n, |
|
|
20 |
* w_i >=0, and G_i's follow the tree structure |
|
|
21 |
* |
|
|
22 |
* The file is implemented in the following in Matlab: |
|
|
23 |
* |
|
|
24 |
* lambdaMax=findLambdaMax(v, n, ind,nodes); |
|
|
25 |
*/ |
|
|
26 |
|
|
|
27 |
void mexFunction (int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]){ |
|
|
28 |
double* v = mxGetPr(prhs[0]); |
|
|
29 |
int n = (int) mxGetScalar(prhs[1]); |
|
|
30 |
double* ind = mxGetPr(prhs[2]); |
|
|
31 |
int nodes = (int) mxGetScalar(prhs[3]); |
|
|
32 |
|
|
|
33 |
double *lambdaMax; |
|
|
34 |
|
|
|
35 |
/* set up output arguments */ |
|
|
36 |
plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); |
|
|
37 |
|
|
|
38 |
lambdaMax = mxGetPr(plhs[0]); |
|
|
39 |
findLambdaMax(lambdaMax,v,n,ind,nodes); |
|
|
40 |
} |