SHOGUN  4.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
eppVector.h
Go to the documentation of this file.
1 /* This program is free software: you can redistribute it and/or modify
2  * it under the terms of the GNU General Public License as published by
3  * the Free Software Foundation, either version 3 of the License, or
4  * (at your option) any later version.
5  *
6  * This program is distributed in the hope that it will be useful,
7  * but WITHOUT ANY WARRANTY; without even the implied warranty of
8  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9  * GNU General Public License for more details.
10  *
11  * You should have received a copy of the GNU General Public License
12  * along with this program. If not, see <http://www.gnu.org/licenses/>.
13  *
14  * Copyright (C) 2009 - 2012 Jun Liu and Jieping Ye
15  */
16 
17 
18 #ifndef EPPVECTOR_SLEP
19 #define EPPVECTOR_SLEP
20 
21 #include <shogun/lib/config.h>
22 #ifdef USE_GPL_SHOGUN
23 
24 #include <stdlib.h>
25 #include <stdio.h>
26 #include <time.h>
27 #include <math.h>
28 #include <shogun/lib/slep/q1/epph.h> /* This is the head file that contains the implementation of the used functions*/
29 
30 
31 /*
32  Lp Norm Regularized Euclidean Projection
33 
34  min 1/2 ||x- v||_2^2 + rho * ||x||_p
35 
36  Usage (in Matlab):
37  [x, c, iter_step]=epp(v, n, rho, p, c0);
38 
39  Usage in C:
40  epp(x, c, iter_step, v, n, rho, p, c0);
41 
42  The function epp implements the following three functions
43  epp1(x, v, n, rho) for p=1
44  epp2(x, v, n, rho) for p=2
45  eppInf(x, c, iter_step, v, n, rho, c0) for p=inf
46  eppO(x, c, iter_step, v, n, rho, p) for other p
47 
48  ------------------------------------------------------------
49 
50  Here, the input and output are of Vector form.
51 
52 
53  Written by Jun Liu, May 18th, 2009
54  For any problem, please contact: j.liu@asu.edu
55 
56 */
57 
58 void eppVector(double *x, double * v, int* ind, int k, int n, double * rho, double rho_multiplier, double p){
59  int i, *iter_step;
60  double c0, c;
61  double *px, *pv;
62 
63  iter_step=(int *)malloc(sizeof(int)*2);
64 
65  c0=0;
66  for(i=0; i<k; i++)
67  {
68  px=x+(int)ind[i];
69  pv=v+(int)ind[i];
70 
71  epp(px, &c, iter_step, pv, (int)(ind[i+1]-ind[i]), rho[i]*rho_multiplier, p, c0);
72  }
73 
74  free(iter_step);
75 }
76 #endif //USE_GPL_SHOGUN
77 #endif /* ----- #ifndef EPPVECTOR_SLEP ----- */
78 

SHOGUN Machine Learning Toolbox - Documentation