function out=diagouter(A,B)
Input:
- A,B:
matrices
Output:
- out:
The expression for the density in Eq. (1) is in the form of
taking as a column vector the diagonal elements of the ``outer
product'' of two matrices,
 |
(10) |
Because
and
are of dimension
, it is
extremely wasteful (of time and memory) to form directly the matrix
matrix
only to then take
its diagonal elements. In this case, it is better to provide our own
function, diagouter(), to perform the using other BLAS operations. In
terms of components Eq. (10) is
Thus, we can perform this operation by first forming the matrix
elements
using octave's ``.*'' and
``conj()'' operators, and then summing along the rows (second index).
In octave notation, this becomes simply
c=sum(A.*conj(B),2);
Use this approach to
produce a function of the above prototype in the file ``diagouter.m''.
Subsections
Tomas Arias
2006-04-26