Re: Using ListCorrelate with Inner
- To: mathgroup at smc.vnet.net
- Subject: [mg87314] Re: Using ListCorrelate with Inner
- From: dh <dh at metrohm.ch>
- Date: Mon, 7 Apr 2008 05:18:32 -0400 (EDT)
- References: <fta9nc$eb5$1@smc.vnet.net>
Hi Art,
Inner is geared towoards tensor analysis. Its arguments are "atomic",
not lists. But ListCorrelate needs lists as arguments. You can achieve
this e.g. by using MapThread:
Total@MapThread[ListCorrelate, {#, d}] & /@ h
This may be shorter, but not more readable.
hope this helps, Daniel
Art wrote:
> I have a matrix of filter vectors h which I would like to
> ListCorrelate with a column of data vectors d as (pseudocode) r =
> Inner[ListCorrelate, h, d, Plus]. I haven't been able to write this in
> a neat form with Inner, which I suspect will also be faster than the
> below:
>
> {l,m,n,o} = {5,5,8,1000};
> h = RandomReal[1., {l,m,n}];
> d = RandomReal[1., {m,o}];
>
> r = Total /@ Table[ListCorrelate[h[[i, j]], d[[j]]], {i, l}, {j,m}]
>
> Thanks,
> Art
>