[d8e26d]: / MLFre / DPC / SLEP / findLambdaMax.c

Download this file

40 lines (34 with data), 1.1 kB

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