SHOGUN
v2.0.0
|
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 EP1R_SLEP 00018 #define EP1R_SLEP 00019 00020 #include <stdlib.h> 00021 #include <stdio.h> 00022 #include <time.h> 00023 #include <math.h> 00024 00025 00026 /* 00027 Euclidean Projection onto l_{2,1} Ball 00028 00029 min 1/2 ||x- u||_2^2 + 1/2 ||t- v||_2^2 00030 s.t. |x|<=t 00031 00032 00033 Usage: 00034 [x, t]=ep1R(u, v, n); 00035 00036 */ 00037 00038 00039 void ep1R(double * x, double *t, double * u, double * v, int n) 00040 { 00041 int j; 00042 00043 00044 for(j=0;j<n;j++){ 00045 00046 if(fabs(u[j]) > fabs(v[j])){ 00047 t[j]=(fabs(u[j]) + v[j])/2; 00048 00049 if (u[j] >0) 00050 x[j]=t[j]; 00051 else 00052 x[j]=-t[j]; 00053 } 00054 else 00055 if(fabs(u[j]) <= v[j]){ 00056 t[j]=v[j]; 00057 x[j]=u[j]; 00058 } 00059 else{ 00060 t[j]=x[j]=0; 00061 } 00062 00063 } 00064 } 00065 #endif /* ----- #ifndef EP1R_SLEP ----- */ 00066