Created
March 7, 2019 01:53
-
-
Save 1f0/55b3c2768ad05c36a8ecfe356cf2f1f0 to your computer and use it in GitHub Desktop.
optimization of quadratic form of [SO_2]^n
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%% f2d.m | |
function f2d(A) | |
x=0:0.05:3*pi; | |
[X, Y]=meshgrid(x); | |
F=zeros(size(X)); | |
min_val = inf; | |
min_coord = [0 0]; | |
max_val = -inf; | |
max_coord = [0 0]; | |
for i=1:size(X,1) | |
for j=1:size(X,2) | |
x=X(i,j); | |
y=Y(i,j); | |
v=[sin(x); cos(x); sin(y); cos(y)]; | |
F(i,j)=v'*A*v; | |
if F(i,j) >= max_val | |
max_val = F(i,j); | |
max_coord = [x y]; | |
end | |
if F(i,j) <= min_val | |
min_val = F(i,j); | |
min_coord = [x y]; | |
end | |
end | |
end | |
surf(X,Y,F); | |
min_val | |
min_coord | |
min_dir=[sin(min_coord(1)) cos(min_coord(1)) sin(min_coord(2)) cos(min_coord(2))] | |
max_val | |
max_coord | |
max_dir=[sin(max_coord(1)) cos(max_coord(1)) sin(max_coord(2)) cos(max_coord(2))] | |
end | |
%% test.m | |
E = [ | |
1 0 0 0 | |
0 2 0 0 | |
0 0 2 0 | |
0 0 0 3 | |
]; | |
E = [ | |
2.92237 -0.13644 -2.15354 -3.46603 | |
-4.21442 3.55869 -3.36019 4.14869 | |
-1.45951 -2.99353 2.42377 -4.66483 | |
-1.69126 3.03281 1.89085 -3.13264 | |
]; | |
a=pi/30; | |
R = [ | |
cos(a) 0 -sin(a) 0 | |
0 1 0 0 | |
sin(a) 0 cos(a) 0 | |
0 0 0 1 | |
]; | |
H = R'*E*R;% rotate a small angle | |
f2d(H) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment