SHOGUN
v3.0.1
首页
相关页面
模块
类
文件
文件列表
文件成员
全部
类
命名空间
文件
函数
变量
类型定义
枚举
枚举值
友元
宏定义
组
页
src
shogun
lib
slep
q1
ep1R.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 EP1R_SLEP
18
#define EP1R_SLEP
19
20
#include <stdlib.h>
21
#include <stdio.h>
22
#include <time.h>
23
#include <math.h>
24
25
26
/*
27
Euclidean Projection onto l_{2,1} Ball
28
29
min 1/2 ||x- u||_2^2 + 1/2 ||t- v||_2^2
30
s.t. |x|<=t
31
32
33
Usage:
34
[x, t]=ep1R(u, v, n);
35
36
*/
37
38
39
void
ep1R
(
double
* x,
double
*t,
double
* u,
double
* v,
int
n)
40
{
41
int
j;
42
43
44
for
(j=0;j<n;j++){
45
46
if
(fabs(u[j]) > fabs(v[j])){
47
t[j]=(fabs(u[j]) + v[j])/2;
48
49
if
(u[j] >0)
50
x[j]=t[j];
51
else
52
x[j]=-t[j];
53
}
54
else
55
if
(fabs(u[j]) <= v[j]){
56
t[j]=v[j];
57
x[j]=u[j];
58
}
59
else
{
60
t[j]=x[j]=0;
61
}
62
63
}
64
}
65
#endif
/* ----- #ifndef EP1R_SLEP ----- */
66
ep1R
void ep1R(double *x, double *t, double *u, double *v, int n)
Definition:
ep1R.h:39
SHOGUN
Machine Learning Toolbox - Documentation