function mc=mac(t1,t2,Q)
%
%   mac
%
%   Computes modal assurance criteria 
%
%
%   mc=mac(phi1,phi2)
%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This matlab source code was originally     %
% developed as part of "DIAMOND" at          %
% Los Alamos National Laboratory. It may     %
% be copied, modified, and distributed in    %
% any form, provided:                        %
%  a) This notice accompanies the files and  %
%     appears near the top of all source     %
%     code files.                            %
%  b) No payment or commercial services are  %
%     received in exchange for the code.     %
%                                            %
% Original copyright is reserved by the      %
% Regents of the University of California,   %
% in addition to Scott W. Doebling, Phillip  %
% J. Cornwell, Erik G. Straser, and Charles  %
% R. Farrar.                                 %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

[ns,n]=size(t1);[ns1,n1]=size(t2);
ns=min([ns,ns1]);
if nargin < 3, Q=eye(ns,ns); end
t1=t1(1:ns,:);t2=t2(1:ns,:);mc=zeros(n,n1);
for i=1:n,
  for j=1:n1,
    mc(i,j)=(t1(:,i)'*Q*t2(:,j))^2/(t1(:,i)'*Q*t1(:,i)*t2(:,j)'*Q*t2(:,j));
  end
end
return
