function OK = CS_feasible_pt(h,x)
% CS_feasible_pt - check if x is in feasible region (Ax+b<=0)
% On input:
%     A (mxn array): m hyperplane normals
%     b (mx1 vector): constant value in hyperplane equation
%     x (nx1 vector): point in n-space
% On output:
%     OK (Boolean): 1 if x is in feasible region; else 0
% Call:
%     OK = CS_feasible_pt([-1,0; 0.7071,0.7071],[1;0],[2,3]);
% Author:
%     T. Henderson
%     UU
%     Summer 2021
%

ZERO_THRESH = 0.0001;

A = h(:,1:end-1);
b = h(:,end);
[m,n] = size(A);

OK = 1;
for k = 1:m
    v = A(k,:)*x + b(k);
    if abs(v)<ZERO_THRESH
        v = 0;
    end
    if v<0
        OK = 0;
        return
    end
end
