SHOGUN
4.1.0
首页
相关页面
模块
类
文件
文件列表
文件成员
全部
类
命名空间
文件
函数
变量
类型定义
枚举
枚举值
友元
宏定义
组
页
src
shogun
lib
slep
q1
ep21R.h
浏览该文件的文档.
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 EP21R_SLEP
18
#define EP21R_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
27
28
/*
29
Euclidean Projection onto l_{2,1} Ball
30
31
min 1/2 ||x- u||_2^2 + 1/2 ||t- v||_2^2
32
s.t. ||x^j||_{2,1} <= t^j
33
34
35
Usage:
36
[x, t]=ep21R(u, v, n, k);
37
38
*/
39
40
41
void
ep21R
(
double
* x,
double
*t,
double
* u,
double
* v,
int
n,
int
k)
42
{
43
int
i, j, tn=n*k;
44
double
temp;
45
46
/* compute the 2 norm of each group
47
*/
48
49
for
(j=0;j<n;j++){
50
temp=0;
51
for
(i=j; i< tn; i+=n)
52
temp+= u[i]* u[i];
53
temp=sqrt(temp);
54
/*temp contains the 2-norm of of each row of u*/
55
56
if
(temp > fabs(v[j])){
57
t[j]=(temp + v[j])/2;
58
for
(i=j; i<tn; i+=n)
59
x[i]= t[j] / temp * u[i];
60
}
61
else
62
if
(temp <= v[j]){
63
t[j]=v[j];
64
65
for
(i=j; i<tn; i+=n)
66
x[i]= u[i];
67
}
68
else
{
69
t[j]=0;
70
71
for
(i=j; i<tn; i+=n)
72
x[i]=0;
73
}
74
75
}
76
}
77
#endif
/* ----- #ifndef EP21R_SLEP ----- */
78
config.h
ep21R
void ep21R(double *x, double *t, double *u, double *v, int n, int k)
Definition:
ep21R.h:41
SHOGUN
机器学习工具包 - 项目文档