ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> numpy-discussion
numpy-discussion
Re: [Numpy-discussion] Tensor-like product with extra indices?
by Huaiyu Zhu other posts by this author
Sep 14 2002 7:24AM messages near this date
Re: [Numpy-discussion] Tensor-like product with extra indices? | [Numpy-discussion] rank-0 arrays
On 13 Sep 2002, Konrad Hinsen wrote:
>  
>  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]

Aagh!  :-)

>  
>  > 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.

I end up using two for-loops, one over j and the other over [A0, ...].  
Hoping the speed problem will not be too bad later on.

Huaiyu

-- 
Huaiyu Zhu <huaiyu_zhu@[...].com> 



-------------------------------------------------------
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

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved