function [member] = linear_order_member(inperm)

% LINEAR_ORDER_MEMBER provides an (n-1) x n partition membership matrix 
% called MEMBER based on the input permutation INPERM of size n.  MEMBER
% defines (with values of 1 and 2) those objects before and after each of
% the n-1 separations in INPERM.  MEMBER is used in the various
% PARTITIONFIT routines.
%
% syntax: [member] = linear_order_member(inperm)

n = length(inperm);

member = 2*ones(n-1,n);

for k = 1:(n-1)
    
    for j = 1:k
        
        member(k,inperm(j)) = 1;
        
    end
end