% law of composition for 2 p-chirp parameter vectors
%
% Use:  c = pcomposew(a,b)
%       gives a \circ b where \circ is the appropriate law of composition
%
% Example: a=corners2d([0.1,.04, .03,.98, .95,.04, .94,.96])
%          a(9)=0; b(9)=0;  % additive gain
%          b=corners2r([0.1,.04, .03,.98, .95,.04, .94,.96])
%          c = pcompose(a,b)   % is approx the identity
%          note this result is equal to pcompose(b,a), though group not Abelian
%
% pcomposew incorporates extra parameter for wyckoff principle

function c = law_of_composition_on(a,b);

A = [a(1) a(2) a(3);  a(4) a(5) a(6);  a(7) a(8) 1];
B = [b(1) b(2) b(3);  b(4) b(5) b(6);  b(7) b(8) 1];

C = A*B; % matrix multiplication

if abs(C(3,3)) < sqrt(eps)
  disp('pcompose.m warning: lower right too close to zero; not dividing')
  c = [C(1,1) C(1,2) C(1,3) C(2,1) C(2,2) C(2,3) C(3,1) C(3,2)];
else%if
  c = [C(1,1) C(1,2) C(1,3) C(2,1) C(2,2) C(2,3) C(3,1) C(3,2)]/C(3,3);
end%if

c(9)=a(9)+b(9);

