-
Notifications
You must be signed in to change notification settings - Fork 14
/
Leval.m
61 lines (61 loc) · 1.33 KB
/
Leval.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
function [L, ifail]=Leval(X,m,p,polycall)
global term
clear L
switch p
case 1
for k=1:m
L(:,k)=X(k,:);
end
case 2
k=0;
for i=1:m
k=k+1;
L(:,k)=X(i,:).^2;
k=k+1;
L(:,k)=sqrt(2).*X(i,:);
for j=i+1:m
k=k+1;
L(:,k)=sqrt(2).*X(i,:).*X(j,:);
end
end
case 3
k=0;
for i=1:m
k=k+1;
L(:,k)=X(i,:).^3;
k=k+1;
L(:,k)=sqrt(3).*X(i,:).^2;
k=k+1;
L(:,k)=sqrt(3).*X(i,:);
for j=i+1:m
k=k+1;
L(:,k)=sqrt(3).*X(i,:).*X(j,:).^2;
k=k+1;
L(:,k)=sqrt(3).*X(i,:).^2.*X(j,:);
k=k+1;
L(:,k)=sqrt(6).*X(i,:).*X(j,:);
for l=j+1:m
k=k+1;
L(:,k)=sqrt(6).*X(i,:).*X(j,:).*X(l,:);
end
end
end
otherwise
if polycall
[term, ifail]=polypower('X',m,p);
else
ifail=0;
end
if ifail>0
L=0;
return
end
k=length(term);
for j=1:k
L(:,j)=eval(term{j});
end
end
ifail=0;
for j=1:k
L(:,j)=(L(:,j)-mean(L(:,j)));
end