SHOGUN  3.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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 #ifndef EPPVECTOR_SLEP
18 #define EPPVECTOR_SLEP
19 
20 #include <shogun/lib/config.h>
21 
22 #include <stdlib.h>
23 #include <stdio.h>
24 #include <time.h>
25 #include <math.h>
26 #include <shogun/lib/slep/q1/epph.h> /* This is the head file that contains the implementation of the used functions*/
27 
28 
29 /*
30  Lp Norm Regularized Euclidean Projection
31 
32  min 1/2 ||x- v||_2^2 + rho * ||x||_p
33 
34  Usage (in Matlab):
35  [x, c, iter_step]=epp(v, n, rho, p, c0);
36 
37  Usage in C:
38  epp(x, c, iter_step, v, n, rho, p, c0);
39 
40  The function epp implements the following three functions
41  epp1(x, v, n, rho) for p=1
42  epp2(x, v, n, rho) for p=2
43  eppInf(x, c, iter_step, v, n, rho, c0) for p=inf
44  eppO(x, c, iter_step, v, n, rho, p) for other p
45 
46  ------------------------------------------------------------
47 
48  Here, the input and output are of Vector form.
49 
50 
51  Written by Jun Liu, May 18th, 2009
52  For any problem, please contact: j.liu@asu.edu
53 
54 */
55 
56 void eppVector(double *x, double * v, int* ind, int k, int n, double * rho, double rho_multiplier, double p){
57  int i, *iter_step;
58  double c0, c;
59  double *px, *pv;
60 
61  iter_step=(int *)malloc(sizeof(int)*2);
62 
63  c0=0;
64  for(i=0; i<k; i++)
65  {
66  px=x+(int)ind[i];
67  pv=v+(int)ind[i];
68 
69  epp(px, &c, iter_step, pv, (int)(ind[i+1]-ind[i]), rho[i]*rho_multiplier, p, c0);
70  }
71 
72  free(iter_step);
73 }
74 #endif /* ----- #ifndef EPPVECTOR_SLEP ----- */
75 

SHOGUN Machine Learning Toolbox - Documentation