[SciPy-user] filling array without loop...
fred
fredmfp@gmail....
Mon Apr 23 08:06:40 CDT 2007
Anne Archibald a écrit :
> On 22/04/07, fred <fredmfp@gmail.com> wrote:
>
>
>> Forget that is a convolution (because in fact, it is really not),
>> simply a scalar product (inner product says scipy) in each cells of an
>> array, as I wrote in my example.
>>
>> Does it changes something ?
>>
>
> Uh, maybe I'm confused -
Ok, so let me explain a little more...
I have two 2D matrices, say A et B, with same dims = 571x876.
B is to be computed, A is known.
Each cell of the matrix B is computed from a "scalar product" with a few
cells of the matrix A and
a "weights" vector W:
B[i,j] = \sum_0^8 w_n a_n
where
- W = [w_n] is a 1D vector (computed from solve(a,b)) with dim = 9
- a_n = A[i,j]
a_n are selected from a submatrix of A (much smaller than A), say A':
a_2 -- a_5 -- a_8
| | |
A' = a_1 -- a_4 -- a_7
| | |
a_0 -- a_3 -- a_6
My idea is to write B[i,j] as a scalar product between W and A'
flattened to a 1D vector:
B[i,j] = dot (W,A')
(ok, inner() method was unadapted)
The problem, from my own opinion, is once again, the two (three in
general case) loops to compute each cell
of the matrix B.
So my question is : is it possible to fill the B matrix without loops ?
I hope I more clear.
Thanks in advance.
Cheers,
--
http://scipy.org/FredericPetit
More information about the SciPy-user
mailing list