%
% Copyright (C) May/June 2005 by Henrik Pagenkopf
%
function Z = intersect_PR(A, B, zero, rec_depth) % approximates A* B via product.m and "regula falsi" intersection.
%
% - cond: A and B are square matrices of same size >= 1 (type-safety of the ojbects used within this project).
%
sa = size(A);
sb = size(B);
if sa(1) >= 1 && sa(1)== sa(2) && sb(1)== sb(2) && sa(1)== sb(1) % => sa(2)== sb(2)
s = sa(1);
C = 0.5 *(A + B); % avg of matrices A and B
[r1,c1,d1]= max_differ_mat(A, B - C);
[r2,c2,d2]= max_differ_mat(A - C, B);
if d1 <= d2 % rule of cases
S = product(A, C, zero, rec_depth -1);
S = S + product(A, B-C, zero, rec_depth -1);
else
S = product( C, B, zero, rec_depth -1);
S = S + product(A-C, B, zero, rec_depth -1);
end; % if(d1)
Z = S; % <- result
else % error
end
% return.