function CRLB=DTDTDOA_CRLB(u,t,S,Q)
% CRLB=DTDTDOA_CRLB(u,t,S,Q)
%
% CRLB for the object and transmitter positions by differential
% time delay (DTD) and TDOA measurements.
%
% Input:
%   u:      (K x 1), object position, K = localization dimension 
%   t:      (K x 1), transmitter position
%   S:      (K x M), sensor positions, M = number of sensors
%   Q:      ((2M-1) x (2M-1)), DTD and TDOA covariance matrix 
%
% Output:
%   CRLB:  (2K x 2K), CRLB for object and transmitter positions
%
% Reference:
% Y. Zhang and K. C. Ho, "Localization by signals of opportunity in the
% absence of transmitter position," IEEE Trans. Signal Process., vol. 72,
% pp. 4602-4617, 2022.
%
% Yang Zhang, K. C. Ho	10-18-2022
%
%       Copyright (C) 2022
%       Computational Intelligence Signal Processing Laboratory
%       University of Missouri
%       Columbia, MO 65211, USA
%       hod@missouri.edu
%

[K,M]=size(S);    % K = dimension, M = number of receivers
                   
Hr=[-ones(M-1,1),eye(M-1)];

rho_ru=repmat(u,1,M)-S; rho_ru=rho_ru./(ones(K,1)*sqrt(sum(rho_ru.^2)));
rho_rt=(t-u)/norm(u-t)*ones(1,M);
rho_u=rho_ru-rho_rt;
rho_dt=repmat(t,1,M)-S; rho_dt=rho_dt./(ones(K,1)*sqrt(sum(rho_dt.^2)));
rho_t=rho_rt-rho_dt;
 
C=[rho_u' rho_t';
   Hr*rho_ru' zeros(M-1,K)];

FIM=C'*inv(Q)*C;
CRLB=inv(FIM);

end
