Print

Print


robin wrote:
> 
> > For some filtering of matrices I need to act on the real and the
> > imaginary part seperately (the filter is real). For now, I
> > copy the real (and imaginary) part into a temporary matrix, and
> > act on these like:
> >   temp(1:N,1:N) = real(mat(1:N,1:N)
> >   call filter(filtercoefs, temp)
> >   erg(1:N,1:N) = temp(1:N,1:N)
> >
> >   temp(1:N,1:N) = real(mat(1:N,1:N)
> >   call filter(filtercoefs, temp)
> >   erg(1:N,1:N) = erg(1:N,1:N) + cmplx(0.0, temp(1:N,1:N))
> 
> Have you considered duplicaing the filter to work on the
> real and the imaginary parts?
> 

the filters are for real and imaginary the same. However, I thought that
you'd save quite a few operations if you work only on real and the
imaginary part seperatly.

mat is complex, filter is real, so a multiplication promotes the filter
to complex, meaning that you'd need 4 multiplies and 2 adds, whereas
you really only need 2 multiplies.

Question arising:
- is the memory jugling worth it?
- are compilers really promoting to complex where you would
need less operations? (I think the standard requires promotion?)

juergen


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%