function vnew=tangent_directions(x,h,v) % TANGENT_DIRECTIONS % % This is an example of a way to add new directions. % % If any point in the stencil does not satisfy the linear constraints, % I will add tangent directions to the stencil. % % The linear constraints, which we handle with the extreme barrier % method, are x(1)/2 + (x(2) - 1)/9 <=1 % vnew=[]; [mv,nv]=size(v); yesno=1; for i=1:nv x_trial=x + h * v(:,i); yesno=yesno*test_constraint(x_trial); end if yesno==0 vnew=zeros(2,2); % % The linear constraints are (1/2, 1/9)^T x <= 10/9. % So a tangent vector is (-1/9, 1/2). We do not have to normalize % this vector because imfil_core will do that. % vnew(:,1)=[-1/9,1/2]'; vnew(:,2)=-vnew(:,1); end function yesno=test_constraint(x) % % val = .5*x(1) + (x(2) - 1)/9; yesno = (val <=1);