eppVector.h

Go to the documentation of this file.
00001 /*   This program is free software: you can redistribute it and/or modify
00002  *   it under the terms of the GNU General Public License as published by
00003  *   the Free Software Foundation, either version 3 of the License, or
00004  *   (at your option) any later version.
00005  *
00006  *   This program is distributed in the hope that it will be useful,
00007  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00008  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00009  *   GNU General Public License for more details.
00010  *
00011  *   You should have received a copy of the GNU General Public License
00012  *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
00013  *
00014  *   Copyright (C) 2009 - 2012 Jun Liu and Jieping Ye 
00015  */
00016 
00017 #ifndef  EPPVECTOR_SLEP
00018 #define  EPPVECTOR_SLEP
00019 
00020 #include <stdlib.h>
00021 #include <stdio.h>
00022 #include <time.h>
00023 #include <math.h>
00024 #include <shogun/lib/slep/q1/epph.h> /* This is the head file that contains the implementation of the used functions*/
00025 
00026 
00027 /*
00028    Lp Norm Regularized Euclidean Projection
00029 
00030    min  1/2 ||x- v||_2^2 + rho * ||x||_p
00031 
00032    Usage (in Matlab):
00033    [x, c, iter_step]=epp(v, n, rho, p, c0);
00034 
00035    Usage in C:
00036    epp(x, c, iter_step, v, n, rho, p, c0);
00037 
00038    The function epp implements the following three functions
00039    epp1(x, v, n, rho) for p=1
00040    epp2(x, v, n, rho) for p=2
00041    eppInf(x, c, iter_step, v,  n, rho, c0) for p=inf
00042    eppO(x, c, iter_step, v,   n, rho, p) for other p
00043 
00044    ------------------------------------------------------------
00045 
00046    Here, the input and output are of Vector form.
00047 
00048 
00049    Written by Jun Liu, May 18th, 2009
00050    For any problem, please contact: j.liu@asu.edu
00051 
00052 */
00053 
00054 void eppVector(double *x, double * v, int* ind, int k, int n, double * rho, double rho_multiplier, double p){
00055     int i, *iter_step;
00056     double c0, c;
00057     double *px, *pv;
00058 
00059     iter_step=(int *)malloc(sizeof(int)*2);
00060 
00061     c0=0;
00062     for(i=0; i<k; i++)
00063     {
00064         px=x+(int)ind[i];
00065         pv=v+(int)ind[i];
00066 
00067         epp(px, &c, iter_step, pv, (int)(ind[i+1]-ind[i]), rho[i]*rho_multiplier, p, c0);
00068     }
00069 
00070     free(iter_step);    
00071 }
00072 #endif   /* ----- #ifndef EPPVECTOR_SLEP  ----- */
00073 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation