Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
test_circle_1.m 706 B
clear all;

if exist('graphics_toolkit','file')
  graphics_toolkit('fltk')
end

A   = [4 1.5; 1.5 3];
b   = [1; 2];
f   = @(x) x + (x > 1) .* (x - 1);
phi = @(x) f(norm(x,2));
J   = @(x) .5*dot(A*x,x) - dot(b,x) + phi(x);

scale = 1.0;

t = -5:0.1:5;
x = scale*cos(t);
y = scale*sin(t);
z = arrayfun(@(vec1, vec2) J([vec1; vec2]), x, y);

hold on
plot3(x,y,z,'k');

title 'scale = 1'

# Minimum taken from test-circle.cc with scale=1

plot3(-1.487905e-01, +9.888687e-01, J([-1.487905e-01; +9.888687e-01]), 'r+');

x = scale * (-1:.05:1);
y = scale * (-1:.05:1);
[X, Y] = meshgrid(x,y);

for i=1:length(y)
  val(i,:) = arrayfun(@(vec1, vec2) J([vec1; vec2]), X(i,:), Y(i,:));
end

surf(x, y, val)
hold off;