spm_trace.m 548 B

1234567891011121314
  1. function [C] = spm_trace(A,B)
  2. % fast trace for large matrices: C = spm_trace(A,B) = trace(A*B)
  3. % FORMAT [C] = spm_trace(A,B)
  4. %
  5. % C = spm_trace(A,B) = trace(A*B) = sum(sum(A'.*B));
  6. %__________________________________________________________________________
  7. % Copyright (C) 2008 Wellcome Trust Centre for Neuroimaging
  8. % Karl Friston
  9. % $Id: spm_trace.m 4805 2012-07-26 13:16:18Z karl $
  10. % fast trace for large matrices: C = spm_trace(A,B) = trace(A*B)
  11. %--------------------------------------------------------------------------
  12. C = sum(sum(A'.*B));