Re: [Numpy-discussion] Tensor-like product with extra indices?
by Konrad Hinsen other posts by this author
Sep 13 2002 10:31AM messages near this date
[Numpy-discussion] Tensor-like product with extra indices?
|
Re: [Numpy-discussion] Tensor-like product with extra indices?
Huaiyu Zhu <huaiyu_zhu@[...].com> writes:
> Two related questions:
>
> 1. Suppose B = ravel(A) and
> B[i] corresponds to A[i0,i1,...].
>
> Are there named functions that map the indices
>
> (i0,i0,...) -> i
>
> and back? This is assuming A.shape = (m0,m1,...) is known.
Untested, but the idea should work:
def ravel_index(array, *indices):
offsets = Numeric.multiply.accumulate(array.shape[1:][::-1])[::-1]
return Numeric.sum(Numeric.array(indices[:-1])*offsets) + indices[-1]
> 2. Suppose the above function is called ravel_index and its
> inverse unravel_index.
>
> Given a list of matrices [A0, A1, ...] is there a function that
> calculates a matrix B such that
>
> B[i,j] = A0[i0,j] * A1[i1,j] * ...
>
> where i = ravel_index(i0, i1, ...).
Not for all i, which I assume is what you want to do.
Konrad.
--
-------------------------------------------------------------------------------
Konrad Hinsen | E-Mail: hinsen@[...].fr
Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.56.24
Rue Charles Sadron | Fax: +33-2.38.63.15.17
45071 Orleans Cedex 2 | Deutsch/Esperanto/English/
France | Nederlands/Francais
-------------------------------------------------------------------------------
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@[...].net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Thread:
Huaiyu Zhu
Konrad Hinsen
Huaiyu Zhu
|